Upgrading to Next.js 16: proxy.ts, Turbopack and async params

By

Published Updated 2 min read

Next.js 16 is mostly an evolutionary upgrade, but a few changes will touch every project. This is the checklist we use.

1. middleware.ts becomes proxy.ts

middleware is renamed to proxy to make its role clearer: it sits at the network boundary in front of your app. The function is exported as proxy and runs on the Node.js runtime.

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


export function proxy(request: NextRequest) {
  if (!request.cookies.has('session')) {
    return NextResponse.redirect(new URL('/login', request.url));
  }
  return NextResponse.next();
}


export const config = {
  matcher: ['/dashboard/:path*'],
};

Keep it small. Authorization for real data must still happen close to the data, not only in the proxy.

2. Turbopack is the default bundler

next dev and next build use Turbopack. Vendor claims are 2x to 5x faster builds and much faster Fast Refresh, but measure your own project. If a custom webpack setup blocks you, opt out explicitly:

Shell
next build --webpack

3. Request APIs are async

params, searchParams, cookies() and headers() are asynchronous. Await them.

TypeScript / React
export default async function Page({
  params,
  searchParams,
}: {
  params: Promise<{ slug: string }>;
  searchParams: Promise<{ page?: string }>;
}) {
  const { slug } = await params;
  const { page = '1' } = await searchParams;
  return <Post slug={slug} page={Number(page)} />;
}

4. Run the codemod and fix the rest

Shell
npx @next/codemod@latest upgrade latest
npm run lint && npm run build

Review the diff rather than trusting it blindly, especially around caching: see our article on Cache Components for the new opt-in model.

Checklist

  • ☐ Node.js and TypeScript versions meet the new minimums
  • ☐ middleware.ts renamed to proxy.ts
  • ☐ All params / searchParams / cookies() awaited
  • ☐ Build passes on Turbopack, or webpack opt-out is documented
  • ☐ Caching behavior re-verified on key pages

Sources and further reading