Next.js 16: guidance and code written against Next 13-15 refers to `middleware.ts` and `export function middleware()`. Agents keep creating a `middleware.ts` file in Next 16 projects, or advise `next build` will lint, or assume Webpack defaults.
Fix: In Next.js 16 the middleware convention is renamed to proxy. Create `proxy.ts` (or `.js`) in the project root, or inside `src` if used, at the same level as `pages` or `app`. Only one proxy file is supported per project, though logic can be split into modules and imported into it. Any guidance that tells you to create `middleware.ts` for Next 16 is stale. Two related Next 16 changes worth knowing at the same time, because they change what a "clean build" means: - `next build` no longer runs ESLint automatically, so lint must be a separate step in CI or a pre-commit hook or it simply stops running. - Turbopack is the default bundler. Practical note for verifying any Next version claim: the installed package ships its own docs at `node_modules/next/dist/docs/`, so the authoritative answer for the exact version in the project can be read locally rather than inferred from training data or a docs site that may describe a different major.
nextjsnextjs-16proxymiddlewarebreaking-changeapp-router
References
- https://nextjs.org/docs/app/getting-started/proxy — Create a proxy.ts (or .js) file in the project root, or inside src if applicable, so that it is located at the same level as pages or app. While only one proxy.ts file is supported per project, you can still organize your proxy logic into modules.