Next.js: the middleware file convention is deprecated, use proxy

Next.js warns that the middleware file convention is deprecated? It has been renamed to proxy. Run the official codemod to rename middleware.ts to proxy.ts.

Reviewed October 25, 2026

What it means in plain English

Next.js's Renaming Middleware to Proxy page says you see this because you are using the middleware file convention, which is deprecated and has been renamed to proxy.

Next.js gives these reasons. The word "middleware" is often confused with Express.js middleware. The name "proxy" better describes what the file does: it sits at a network boundary in front of the app. Next.js also says it recommends using this feature only as a last resort, when no other API does the job.

Likely causes

  • Your project has a middleware.ts or middleware.js file with an exported middleware function, written before the rename.
  • An AI tool or a template generated the file with the old name.

How to fix it, step by step

  1. Commit your work first, so you can see exactly what the codemod changes.
  2. In the project folder, run Next.js's codemod:
npx @next/codemod@canary middleware-to-proxy .
  1. Next.js says the codemod renames the file and the function from middleware to proxy. Check the diff. It should look like this:
// middleware.ts -> proxy.ts

- export function middleware() {
+ export function proxy() {
  1. Next.js's Proxy page says Proxy defaults to the Node.js runtime, and that setting the runtime config option in a Proxy file throws an error. If your old middleware file sets runtime, remove it.
  2. Run the dev server and next build, then deploy.

How to check it worked

  • The deprecation message no longer appears when you run the app.
  • Routes that relied on the old middleware, such as auth redirects, still behave the same.

Sources

More Next.js errors fixes

Keep going on your own.

The guides stay free. A deep leak report is $15. Fix packs are $24, or $49 for all three. There is no done-for-you repair.

See products