{
  "id": 18001896,
  "title": "Next.js Middleware to Proxy: How to Migrate middleware.ts to proxy.ts in Next.js 16",
  "url": "https://urgent.news/2026/11/03/next-js-middleware-to-proxy-how-to-migrate-middleware-ts-to-proxy-ts",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-03T18:22:35.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/fabwaseem/nextjs-middleware-to-proxy-how-to-migrate-middlewarets-to-proxyts-in-nextjs-16-1n35"
  },
  "original_language": "en",
  "account": "In Next.js 16, the middleware.ts file has been deprecated and renamed to proxy.ts. While existing middleware still runs, every build now prints a deprecation warning. This guide outlines the migration process step by step, with warnings and errors observed from Next.js 16.4.5 on a small test app.\n\nMiddleware vs proxy:\nThe behavior remains the same feature under a new name. The exported function name changes from middleware to proxy, and Proxy always runs on the Node.js runtime.\n\nStep 1: Deprecation warning\nAfter implementing auth-redirect middleware in Next.js 16.4.5, the codemod generated a deprecation warning:\n⚠ The middleware file convention is deprecated. Please use proxy instead.\n\nStep 2: Run the codemod\nRunning npx @next/codemod@canary middleware-to-proxy automatically renamed middleware.ts to proxy.ts and changed the exported function from middleware to proxy. No other changes were made, and the build ran without deprecation warnings. Subsequently, tests confirm that the redirected URL includes the session cookie and that the x-user header is set correctly.\n\nStep 3: Manual migration (if codemod not possible)\nTwo edits are required: rename middleware.ts to proxy.ts and rename the exported function to proxy (or use a default export). If pageExtensions was customized, the filename should follow the new convention.\n\nPotential migration errors:\n- Both middleware and proxy files are detected: delete the old middleware.ts file.\n- Proxy does not support Edge runtime: remove runtime from the config or switch to the experimental-edge value.\n\nAfter migration, matchers remain unchanged, execution order stays the same, and skipMiddlewareUrlNormalize is now skipProxyUrlNormalize. Testing helpers have been updated, with unstable_doesProxyMatch replacing unstable_doesMiddlewareMatch. Proxy should not be used as the sole authentication check.",
  "summary": "Cross-posted from my blog. The original, with any updates, lives on fabwaseem.com . In Next.js 16, middleware.ts is deprecated and renamed to proxy.ts . Your existing middleware still runs, but every build now prints a deprecation warning, and a few things behave differently: the function name changes, Proxy always runs on the Node.js runtime, and having both files in a project fails the build.…",
  "key_points": [
    "Middleware.ts deprecated, renamed to proxy.ts in Next.js 16",
    "Exported function name changed from middleware to proxy",
    "Codemod tool automates renaming and function change"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}