Nextjs Fundamentals · Next.js 16 Upgrade

middleware → proxy

the `proxy.ts` rename

middleware → proxy

Next.js 16 renames Middleware to Proxy. The feature is unchanged — it still intercepts requests at the network boundary before a request completes — but the file and the exported function are renamed to make that boundary explicit.

Rename middleware.ts to proxy.ts and rename the exported function to proxy:

// proxy.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

export function proxy(request: NextRequest) {
  return NextResponse.redirect(new URL('/home', request.url));
}

export const config = {
  matcher: '/about/:path*',
};

The config.matcher option is unchanged: it still filters which paths run through Proxy, so it only runs where you need it. Configuration flags that carried the old name change too — for example skipMiddlewareUrlNormalize becomes skipProxyUrlNormalize.

Two runtime details matter. Proxy runs on the Node.js runtime, and this cannot be configured. If you still need the Edge runtime, middleware.ts remains available, but it is deprecated and will be removed in a future version, so plan the migration.

proxy.ts is for rewrites, redirects, and header changes — not slow data fetching or full authorization.

You are about to answer a short quiz on the proxy.ts rename.

  1. In Next.js 16, `middleware.ts` is renamed to `proxy.ts`.
  2. The exported function in `proxy.ts` should be renamed to ___.
  3. The `config.matcher` option changes as part of the rename to `proxy.ts`.
  4. The Next.js 16 file you rename from `middleware.ts` is ___.
  5. `middleware.ts` is deprecated in favour of `proxy.ts`.
  6. Proxy runs on the Edge runtime by default in Next.js 16.