GeekDas
••10 min read•
GeekdasGeekdas

Next.js 16 Explained: Cache Components, Turbopack, proxy.ts and the React Compiler

Next.js 16 Explained: Cache Components, Turbopack, proxy.ts and the React Compiler

Next.js 16 is the release where several long-running experiments became the default way to build. Turbopack is the standard bundler, caching is now explicit and opt-in, the React Compiler is supported, and middleware.ts has a new name and a clearer role. Point releases since then have kept going: 16.2 stabilised the adapter API for hosting platforms, 16.3 focused on faster dev and builds, and 16.4 added lazy compilation and smaller Turbopack output.

If you have an App Router project on Next.js 14 or 15, this guide explains what changed, what might break and how to upgrade in a sensible order. It is written for working developers, with short code samples and a focus on decisions rather than release-note trivia. Always cross-check specifics against the official upgrade guide for the exact version you install.

Next.js 16 at a glance

  • Turbopack is the default bundler for development and production builds.

  • Cache Components introduce an explicit, opt-in caching model built on the use cache directive.

  • proxy.ts replaces middleware.ts as the place for request interception, running on the Node.js runtime.

  • React Compiler support is stable, so memoisation can be automated.

  • React 19.2 features such as View Transitions and useEffectEvent are available.

  • Async request APIs are fully enforced: params, searchParams, cookies() and headers() must be awaited.

  • Higher minimums: Node.js 20.9 or newer and TypeScript 5.1 or newer.

Turbopack becomes the default

For years, Turbopack was the fast new thing you could try with a flag. In Next.js 16 it is what next dev and next build use unless you opt out. The practical result is quicker cold starts, faster refresh while you edit and shorter production builds, particularly on large projects. Vercel's launch post cites 2 to 5 times faster production builds and up to 10 times faster Fast Refresh, though your numbers will depend on your codebase.

What to check before you rely on it

  • Custom webpack config: if you have a webpack function in next.config.js, Turbopack will not run it. Look for loaders and plugins you can replace with built-in features, or keep webpack for that project by passing the --webpack flag.

  • Unusual loaders: SVG loaders, raw imports and custom file handling are the most common friction points.

  • Filesystem caching: Turbopack can persist its cache between runs. It began as a beta feature, and the current upgrade guide describes it as enabled for both dev and build, which speeds up repeated builds.

Turbopack has matured quickly, and the 16.x point releases have focused heavily on closing compatibility gaps, so retest if something failed on an earlier version.

Cache Components and the use cache directive

This is the most significant conceptual change. In earlier App Router versions, Next.js cached aggressively by default, and many developers were surprised by stale data or spent time figuring out how to turn caching off. Cache Components flip that: dynamic code runs at request time by default, and you opt in to caching exactly where you want it.

Turning it on

// next.config.js
module.exports = {
  cacheComponents: true,
};

Caching a component or function

Add the use cache directive to a component, a function or a whole file, and describe how long and under what label the result should live:

import { cacheLife, cacheTag } from 'next/cache';

export async function PopularPosts() {
  'use cache';
  cacheLife('hours');
  cacheTag('posts');

  const posts = await fetch('https://api.example.com/posts/popular').then((r) => r.json());
  return (
    <ul>
      {posts.map((p) => (
        <li key={p.id}>{p.title}</li>
      ))}
    </ul>
  );
}

cacheLife controls how long the entry is considered fresh, using built-in profiles (seconds, minutes, hours, days, weeks and max) or a custom one. cacheTag attaches a label so you can invalidate the entry later. Current docs also ask you to set partialPrefetching: true explicitly alongside cacheComponents, so check the guide for your version.

Partial prerendering without the guesswork

Cache Components pairs naturally with partial prerendering. The static shell of the page, plus any cached pieces, is prepared ahead of time and served instantly, while truly dynamic parts stream in. You wrap request-time pieces in Suspense, and Next.js fills them in as they resolve. The result is the speed of a static site with the freshness of a dynamic one, without you labelling the whole route as one or the other.

A mental model that works

Think of every piece of UI as one of three things: static (known at build time), cached (computed once and reused for a while) or dynamic (computed per request). Cache Components make you name which one it is. That explicitness is the feature.

The updated caching APIs

The new model comes with sharper tools for invalidation.

  • revalidateTag(tag, profile) now takes a cache life profile as a second argument, so you decide how stale content may be served while the new version is generated.

  • updateTag(tag) is meant for Server Actions. It expires the entry and refreshes it immediately, so the person who just saved a form sees their own change on the next render. Use it for "read your writes" cases such as editing a profile or posting a comment.

  • refresh() is called from a Server Action to refresh the current page's uncached data without touching the cache, which is handy for things like a notification count.

A quick rule of thumb: use updateTag when the user who made the change needs to see it right now, and revalidateTag when slightly stale content for other visitors is fine.

proxy.ts replaces middleware.ts

The middleware file name confused many people, because it did not behave like Express middleware. Next.js 16 renames it to proxy.ts to make its role clear: it sits at the network boundary, in front of your app, and handles redirects, rewrites, headers and simple request checks.

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

export function proxy(request: NextRequest) {
  if (!request.cookies.get('session') && request.nextUrl.pathname.startsWith('/dashboard')) {
    return NextResponse.redirect(new URL('/login', request.url));
  }
  return NextResponse.next();
}

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

What changes in practice

  • Rename the file and the exported function from middleware to proxy.

  • proxy.ts runs on the Node.js runtime, so more Node APIs are available than in the old edge-only setup.

  • The old middleware.ts still exists for edge runtime use cases but is deprecated, so plan the migration.

  • Keep proxy logic light. Authorisation for sensitive data should still be checked close to where the data is read, not only in the proxy.

React Compiler support

The React Compiler analyses your components and adds memoisation automatically, so you write fewer useMemo, useCallback and React.memo calls. Support is stable in Next.js 16, and you opt in with a single option after installing the Babel plugin:

// next.config.js
module.exports = {
  reactCompiler: true,
};
npm install -D babel-plugin-react-compiler

Expect somewhat longer compile times because the compiler uses Babel. In exchange, you often get fewer unnecessary re-renders without manual tuning. Roll it out gradually: enable it, run your tests, profile a few heavy screens and look for components that rely on subtle mutation, which the compiler may skip.

Features that arrive with React 19.2

The App Router in Next.js 16 uses the latest React Canary, which includes React 19.2 features such as:

  • View Transitions for animating elements that change between navigations.

  • useEffectEvent for reading the latest props or state inside an effect without re-triggering it.

  • Activity for hiding parts of the UI while keeping their state alive, useful for tabs and background routes.

These are optional, so adopt them when a real problem calls for them.

Async request APIs are now mandatory

In Next.js 15, accessing params, searchParams, cookies() and headers() synchronously still worked with a warning. In 16 you must await them. This is the change most likely to produce build errors in an older codebase.

// app/blog/[slug]/page.jsx
export default async function Page({ params }) {
  const { slug } = await params;
  const post = await getPost(slug);
  return <article>{post.title}</article>;
}

The same applies to generateMetadata, route handlers and layouts that read params. A codemod handles most of the mechanical changes, but read the diff because it cannot always infer your intent.

Breaking changes and removed features

Check these before upgrading:

  • Minimum versions: Node.js 20.9 or newer, and TypeScript 5.1 or newer.

  • next lint is removed. Run ESLint or Biome directly from your scripts.

  • AMP support is removed.

  • Runtime config options such as serverRuntimeConfig and publicRuntimeConfig are removed in favour of environment variables.

  • Experimental flags such as experimental.ppr and experimental.dynamicIO are removed in favour of cacheComponents.

  • Image defaults changed: the default minimumCacheTTL went from 60 seconds to 4 hours, and local IP addresses are blocked unless you allow them. If you rely on remote images, confirm your remotePatterns.

  • Deprecated APIs from earlier versions may be gone, so clear all warnings in your current version first.

How to upgrade: a safe order of operations

Step 1: Get to a clean baseline

Upgrade to the latest 15.x release first if you are on an older version, fix every deprecation warning and make sure your tests pass. Upgrading across two majors at once makes failures hard to attribute.

Step 2: Run the upgrade codemod

npx @next/codemod@canary upgrade latest

The tool bumps versions, applies codemods such as async request API changes and the proxy rename, and prints the items it could not handle.

Step 3: Fix and test

Review the diff, run type checks, then run the app in development and click through your main routes. Pay attention to authentication, forms and any page that depended on implicit caching.

Step 4: Adopt new features one at a time

Turn on cacheComponents, then reactCompiler, in separate pull requests. If something regresses, you will know which switch caused it.

Should you upgrade now?

If you are starting a new project, use 16, since you get the current defaults and the best tooling. For an existing production app, upgrade when you have a test suite, a staging environment and a day or two to deal with surprises. If you depend on a heavily customised webpack setup or an edge-only middleware stack, schedule a longer migration and test it thoroughly.

If you would like a hand planning a migration, performance work or a rebuild on the latest stack, my Next.js developer hiring guide explains what to look for, and my custom website development service covers the work itself.

Conclusion

Next.js 16 is less about flashy new APIs and more about making the framework predictable. Caching is explicit, builds are faster, the request boundary has an honest name and automatic memoisation is available. Upgrade methodically, adopt Cache Components deliberately and keep an eye on the changelog for 16.x point releases. The effort is worth it for the clarity you get in return.

Was this article helpful?

Comments

Leave a comment

Loading comments...

Frequently Asked Questions

What is new in Next.js 16?
The headline changes are Turbopack as the default bundler, Cache Components with the use cache directive, proxy.ts replacing middleware.ts, stable React Compiler support, React 19.2 features and mandatory async request APIs. It also raises the minimum Node.js version to 20.9 and removes features such as AMP support and the next lint command.
What are Cache Components in Next.js?
Cache Components are an opt-in caching model. Code runs at request time by default, and you mark specific components or functions with the use cache directive, then control freshness with cacheLife and invalidation with cacheTag. They work with partial prerendering so static and cached parts load instantly while dynamic parts stream in.
Is middleware.ts removed in Next.js 16?
It is deprecated rather than removed. The recommended replacement is proxy.ts, which runs on the Node.js runtime. The old middleware file remains for edge runtime use cases, but new code should use proxy.ts, and existing projects should plan a migration.
Do I need to rewrite my app to upgrade from Next.js 15?
Usually not. Most changes are mechanical, such as awaiting params and searchParams, renaming middleware to proxy and removing deprecated config. Run the official upgrade codemod, fix the remaining errors, and test caching-sensitive pages carefully. Adopt Cache Components and the React Compiler afterwards, one at a time.
Should I enable the React Compiler?
It is stable and often reduces unnecessary re-renders, but it is opt-in. Install the Babel plugin, set reactCompiler to true, run your tests and profile a few heavy screens. Expect slightly longer build times. If a component relies on unusual mutation patterns, check that it still behaves correctly.
Is Turbopack production-ready?
In Next.js 16 it is the default for both development and production builds, and later 16.x releases keep improving compatibility. If you have a custom webpack configuration or unusual loaders, test them first, and use the documented opt-out flag if you must stay on webpack for now.

Related Articles