All articles

Next.js 16: middleware.ts is now proxy.ts

If you upgrade to Next.js 16 and your middleware.ts stops doing what you expect — it wasn't deleted. It was renamed.

middleware.ts → proxy.ts. The exported function changes too: middleware → proxy. The logic inside stays exactly the same.

Why the rename: "middleware" made everyone think of Express middleware — a step in a request chain inside your app. That's not what it is. It sits in front of your app, at the network boundary. "Proxy" says that out loud. proxy runs on the Node.js runtime; middleware.ts still works for Edge cases but is deprecated and going away.

Three things worth knowing before you upgrade

  • There's a codemod. It renames the file and the function for you. Don't do it by hand.
  • Config flags renamed too. skipMiddlewareUrlNormalize → skipProxyUrlNormalize. Easy to miss — it fails quietly.
  • Check your auth libraries. Anything that shipped its own middleware.ts wiring (next-intl, auth helpers) needs its integration updated, not just the filename.

What actually lives in mine: about 200 lines running on every matched request at Navoy — reading the session cookie, checking token expiry, and redirecting before a page ever renders. That's the part people underestimate. It isn't a routing detail; it's the gate every request passes through. Naming it "proxy" makes that obvious to the next person reading the repo.

Renames are boring. Renames that fix a wrong mental model are not.

Upgraded to 16 yet — did anything catch you out?