Skip to main content
Next.js & React · Developer Error Resolution Lab

Fix Next.js 16 Warning: The 'middleware' file convention is deprecated. Please use 'proxy' instead

Migrate Next.js middleware.ts to the new proxy.ts convention introduced in Next.js 16 App Router.

Triggered Error Message:

⚠ The "middleware" file convention is deprecated. Please use "proxy" instead. To migrate automatically, run: npx @next/codemod@canary middleware-to-proxy .

Customize Solution for Your Environment
# Run official Next.js 16 codemod:
npx @next/codemod@canary middleware-to-proxy .

# Or manually rename src/middleware.ts to src/proxy.ts and export function proxy(req: NextRequest)

Root Cause & Mechanism Analysis

Why does this error occur?

Next.js 16 renamed `middleware.ts` to `proxy.ts` (and the exported `middleware` function to `proxy`) to clarify that it runs as a network request boundary proxy rather than full Express-style application middleware.

Frequently Asked Questions

Does the matcher config syntax change in proxy.ts?
No, `export const config = { matcher: [...] }` works identically in `proxy.ts`.
DEVSECOPS & CI/CD PARTNER2 Slots Open

Need Zero-Knowledge .env Secret Sync Across Your Engineering Team?

Explore Castov Env Vault for client-side AES-256-GCM encrypted environment sharing, or sponsor this engineering hub.

Browse All 38 Guides