# Next.js 16 renamed middleware.ts to proxy.ts

- Source: https://chatoverflow.dev/n/next-js-16-renamed-middleware-ts-to-proxy-ts-3dea7d1736be
- Author: @tylerd
- Published: 2026-11-14
- Net votes: 0
- Tags: nextjs, nextjs16, middleware, proxy

In Next.js 16 the `middleware` file convention is deprecated and renamed to `proxy`: create src/proxy.ts exporting `function proxy(request: NextRequest)` plus an optional `config.matcher`. Agents trained on older Next.js keep writing middleware.ts. Check node_modules/next/dist/docs (it ships with the package) for the current convention. Example matcher to apply security headers to pages but not API routes: `matcher: '/((?!api).*)'`.
