3 min 15 sec read

Next.js 16 Released: Turbopack Default, Cache Components, and the New proxy.ts

Next.js 16 is stable! Discover the new "use cache" directive, the migration from middleware.ts to proxy.ts, and how to use the AI-powered DevTools MCP. Upgrade guide included.

logo
Maurya Patel

Next.js 16: Stability, Speed, and "Opt-in" Caching

Next.js 16 has officially landed. Unlike previous releases that felt like experimental leaps, version 16 is a massive stabilization effort. It solidifies the architecture introduced in the App Router and fixes the biggest pain points developers have faced: unpredictable caching and slow dev servers.

This is a "maturity" release. It makes the framework faster by default (Turbopack), clearer in its network boundaries (proxy.ts), and smarter in how it handles data (use cache).

Here is a comprehensive technical breakdown of what has changed and how to implement it.

1. Cache Components: The "Opt-in" Revolution

For the last two years, the biggest complaint about Next.js was its aggressive "cache everything by default" strategy. If you didn't explicitly opt-out, you often got stale data.

Next.js 16 completely flips this model. We now have Cache Components and the use cache directive.

  • Default Behavior: Everything is dynamic.
  • Cached Behavior: You explicitly opt-in using 'use cache'.

This feature is built on Partial Pre-Rendering (PPR), allowing you to cache static shells while streaming dynamic parts.

Step 1: Enable the Feature You need to enable the flag in your configuration.How to use it:You can now cache specific components or functions with a single line.

next.config.ts
1// next.config.ts
2import ‍​type ‍​{ ‍​NextConfig ‍​} ‍​from ‍​'next';
3
4const ‍​nextConfig: ‍​NextConfig ‍​= ‍​{
5 ‍​ ‍​experimental: ‍​{
6 ‍​ ‍​ ‍​ ‍​cacheComponents: ‍​true, ‍​// 👈 Unlocks 'use cache' and PPR
7 ‍​ ‍​ ‍​ ‍​// ppr: true // (Optional) often enabled automatically with cacheComponents
8 ‍​ ‍​},
9};
10
11export ‍​default ‍​nextConfig;

Step 2: Usage at Component or Function Level You can now granularly cache a specific component, a single function, or an entire file.

// app/components/StockTicker.tsx
import ‍​{ ‍​cacheLife ‍​} ‍​from ‍​'next/cache';

export ‍​async ‍​function ‍​StockTicker() ‍​{
 ‍​ ‍​'use cache'; ‍​// 👈 Directs Next.js to cache this component's output
 ‍​ ‍​
 ‍​ ‍​// Define how long this should live (stale-while-revalidate logic)
 ‍​ ‍​cacheLife('minutes'); ‍​// profiles: 'seconds', 'minutes', 'hours', 'days', 'max'

 ‍​ ‍​const ‍​data ‍​= ‍​await ‍​fetchStockData(); ‍​
 ‍​ ‍​return ‍​<div ‍​className="ticker">{data.price}</div>;
}

Note

The cacheLife function abstracts away complex revalidate and expire math into simple profiles.

2. Breaking Change: middleware.ts is now proxy.ts

If you try to run a Next.js 16 app with a middleware.ts file, it might work for now, but you should migrate immediately. The file has been renamed to proxy.ts to clarify its role as a network boundary.

The Critical Change:

  • Old (middleware.ts): Ran on the Edge Runtime (limited API support).
  • New (proxy.ts): Runs on the Node.js Runtime by default.

This is huge. You can now use standard Node.js APIs (like database connections or logging libraries that weren't Edge-compatible) directly in your proxy file.

Migration Code: Rename your file to proxy.ts and update the export:

proxy.ts
1// proxy.ts (formerly middleware.ts)
2import ‍​{ ‍​NextResponse ‍​} ‍​from ‍​'next/server';
3import ‍​type ‍​{ ‍​NextRequest ‍​} ‍​from ‍​'next/server';
4
5export ‍​function ‍​proxy(request: ‍​NextRequest) ‍​{
6 ‍​ ‍​// Authentication logic, redirects, headers
7 ‍​ ‍​if ‍​(request.nextUrl.pathname.startsWith('/admin')) ‍​{
8 ‍​ ‍​ ‍​ ‍​return ‍​NextResponse.rewrite(new ‍​URL('/login', ‍​request.url));
9 ‍​ ‍​}
10 ‍​ ‍​return ‍​NextResponse.next();
11}

3. DevTools MCP: Debugging with AI

Next.js 16 introduces a native integration with the Model Context Protocol (MCP). This isn't just a buzzword; it connects your running dev server to AI assistants like Cursor, Claude, or GitHub Copilot.

Normally, when you paste an error into ChatGPT, it guesses the solution. With MCP, the AI can query your dev server directly.

Capabilities:

  1. Read Server Logs: The AI sees the exact error trace from your terminal.
  2. Inspect Component Tree: It knows you are on layout.tsx nested inside (dashboard).
  3. Access Environment: It can see (safe) config values to debug routing issues.

Setup: Run the initialization command to create a .mcp.json file:

npx ‍​next-devtools-mcp@latest ‍​init

4. Turbopack is Stable & Default

After years of development, Turbopack has graduated. It is now the default bundler for all new Next.js 16 projects.

  • Production Builds: 2-5x faster than Webpack.
  • Fast Refresh: Up to 10x faster (sub-100ms updates).

Legacy Support: If you have a massive custom Webpack config, you can still opt-out using next dev --webpack, but the team is encouraging everyone to move over.

5. The New Caching APIs

To support the new "Cache Components" model, the data-fetching APIs have been refined to be more explicit about consistency.

A. revalidateTag(tag, profile)

In previous versions, revalidating a tag wiped the cache instantly. Now, it supports Stale-While-Revalidate (SWR). You must pass a second argument (the profile) to tell Next.js how to handle the update.

// Revalidate, but serve old data while fetching new data in background
await ‍​revalidateTag('products', ‍​'hours');

B. updateTag(tag) (For Server Actions)

This is a new API designed for "Read-Your-Writes" consistency. Use this inside Server Actions when a user submits a form. It forces an immediate cache purge so the user sees their update instantly.

'use server';
import ‍​{ ‍​updateTag ‍​} ‍​from ‍​'next/cache';

export ‍​async ‍​function ‍​updateProfile(formData: ‍​FormData) ‍​{
 ‍​ ‍​await ‍​db.updateUser(formData);
 ‍​ ‍​// Immediate purge: User sees new name instantly
 ‍​ ‍​updateTag('user-profile'); ‍​
}

Verdict: A Necessary Upgrade

Next.js 16 is a powerhouse release. The shift to proxy.ts solves the Edge Runtime headaches, and use cache finally gives us the control we've been asking for.

Upgrade Command:

npm ‍​install ‍​next@latest ‍​react@latest ‍​react-dom@latest

Enjoyed this article?

Share it with your network or friends.