This release speeds up production builds with Turbopack, lets unchanged remote caches carry over across deployments, and adds improvements to bundle analysis and Partial Prefetching.
Here's what's new in 16.5:
Faster Turbopack builds. In our benchmarks on Vercel's dashboard, cold compilation is ~4.2× faster and uses 38% less memory, and the on-disk cache is 14% smaller.
Cross-deployment caching. Functions marked with 'use cache: remote' can read cached entries from a previous deployment when their code and dependencies haven't changed.
Per-link navigation prefetching. Setting prefetch="navigation" lets an individual <Link> prefetch cached content that navigation() would otherwise defer until click.
Automatically upgrade your app in CI.next upgrade --ci sets up a GitHub Actions workflow where a coding agent upgrades your app and opens a pull request when a new release ships.
Safe mode for image optimization. A new experimental next/image optimization implementation that uses sandboxing and memory-safe image decoders to reduce security risks associated with processing untrusted images.
Next.js 16.5 also introduces experimental native Route Handler support, starting with Go Route Handlers, so you can write a route.go file alongside your TypeScript routes.
Upgrade today with a coding agent, or install next@latest directly:
The rise of agentic development has brought new challenges to build tools. Instead of one developer using their machine to work on one or two projects at a time, today that same developer may use a fleet of agents to run dozens of Next.js servers simultaneously on that same computer.
To support these new workflows, we've focused on improving Turbopack's build performance in a few key areas:
Better utilization of all available CPU cores during builds
Ensuring applications can scale to thousands of routes
Reducing memory and disk space overheads to keep applications inside build container limits
To measure the impact of this work, we benchmarked compilation of Vercel's dashboard on a 30-core, 60 GB build machine.
Compile times on a cold start in 16.5 were four times as fast as they were in 16.4.6, which is especially beneficial for agents as they tend to work from a fresh checkout.
Full production builds also benefited from these changes, with cold builds cutting their time in half:
We also optimized Turbopack to use memory and disk space more efficiently:
Across five other Vercel apps we benchmarked, including nextjs.org, we saw reductions in peak memory by 6%-27% and disk cache sizes by up to 23%.
Previously, deploying a new version of your app would effectively reset the cache for every function that used 'use cache: remote'. This is because Next.js included the build or deployment ID in each function's cache key, to prevent cache entries from returning stale data in the event their code or dependencies changed.
For example, say you had a function like getProduct:
app/catalog/data.ts
import { db } from "@/lib/db";
export async function getProduct(id: string) {
"use cache: remote";
return db.product.findUnique({ where: { id } });
}
Even if you edited an unrelated page and didn't change getProduct at all, redeploying your app meant that this function would have to query the database again the first time it executed in this new deployment.
Next.js 16.5 fixes this. Functions using 'use cache: remote' now have the ability to reuse their entries across deployments.
In 16.5, Turbopack scans your cached functions and their dependencies to generate each cache key from the function itself, the code it depends on, and the environment values it reads.
If you make an unrelated change and redeploy, and getProduct's code and dependencies haven't changed, the new deployment can reuse the cache entries from the previous one.
Entries still expire and revalidate as usual. Next.js also stops reusing an entry if any of the function's transitive imports or any of the environment values it reads change.
When Turbopack can't determine everything a function depends on, Next.js falls back to a deployment-specific key, just as before. Notably, this happens when accessing process.env in a dynamic way, such as process.env[variable] or parseConfig(process.env).
This writes the report to .next/diagnostics/analyze, and can be used during builds on CI so changes to your bundles can be tracked over time.
In Next.js 16.5, you can use the new --analyze option to generate a report during your normal production builds:
Terminal
npx next build --analyze
This lets you avoid running a second compilation of your app, and also guarantees that the JavaScript, CSS, and source maps you see in the bundle report match your production deployment exactly.
Next.js 16.4 introduced a new experimental garbage collector that cleaned up unused compilation work during long dev sessions via the turbopackGc flag.
In 16.5, we're enabling this feature by default for all apps.
With garbage collection enabled, Turbopack's cache only grows with the size of your application, rather than with the number of changes to it, keeping updates fast during rebuilds.
Request Insights is a new tool that shows where a slow App Router request spends its time in development. In 16.5, next dev keeps the 500 most recent requests in memory by default. Select a request in Next.js DevTools to see how long compilation, module , data fetching, and rendering took.
You can also ask a coding agent why a route is slow. For slow server requests, the next-performance skill reproduces the request and reads its timeline through the CLI. For slow startup or navigation in the browser, it uses next-bundle-optimizer from Next.js 16.4 to inspect the route's JavaScript with the Turbopack Bundle Analyzer.
In Next.js 16.4, we released the navigation() API. You can use this API to exclude content from a prefetch, letting you avoiding rendering secondary content until an actual navigation takes place.
The example from the 16.4 blog post showed using it to exclude an email's replies from being rendered during the Inbox's prefetches:
import { navigation } from 'next/cache';
async function Message({ id }) {
const message = await getMessage(id);
return (
<>
<p>{message.subject}</p>
<div>{message.body}</div>
<Suspense fallback={<Spinner />}>
<Thread id={id} />
</Suspense>
</>
);
}
async function Thread({ id }) {
await navigation(); // Exclude Threads from being prefetched
const thread = await getThread(id);
return (
<>
{thread.map((message) => (
<div key={message.id}>{message.body}</div>
))}
</>
);
}
This let the Inbox render prefetched links, without having to fully load every single message's thread:
<nav>
{messages.map((message) => (
<Link
href={`/message/${message.id}`}
key={message.id}
prefetch
>
{message.subject}
</Link>
))}
</nav>
But sometimes you might have a specific link that you know the user is very likely to click next. In that case, you may want that link to more aggressively prefetch all the possible cached content from the upcoming page, even content that's behind an await navigation().
In the email app example, you might have a single "Next unread" button that is a good candidate for prefetching both the message and the complete thread, as it doesn't appear in a long list of links like the rest of the Inbox.
In Next.js 16.5, you can use <Link prefetch='navigation'> to prefetch all cached content for a target page, even content that would otherwise be deferred by await navigation():
<Link href="https://nextjs.org/message/42" prefetch="navigation">
Next unread
</Link>
Once "Next unread" enters the viewport, Next.js prefetches the full thread, so all the content is instantly ready by the time the user clicks.
next upgrade --agent lets a coding agent upgrade your app on demand. In 16.5, you can also run that upgrade in CI on a schedule with GitHub Actions:
Terminal
npx next@canary upgrade --ci
The command asks which upgrades to check for (security advisories only, or every new stable release) and which hosted agent to use: Codex or Claude Code, with an OpenAI or Anthropic API key, a Vercel AI Gateway key, or a Claude subscription. It then opens a pull request that adds the workflow and helps you store the credentials as repository secrets.
Once merged, the workflow checks for a new release every day. When one matches your policy, the agent upgrades the app and opens a pull request with the result for you to review.
You can also ask your coding agent to run next upgrade --ci for you; it picks sensible defaults and opens the setup pull request without prompting.
Next.js 16.5 introduces experimental native Route Handler support, starting with Go. You can add a route.go file anywhere in the App Router alongside your TypeScript routes, and Turbopack compiles it into a native executable served at that route path while the rest of your app stays in TypeScript.
To try a Go Route Handler, install Go 1.24 or later and enable goRoutes in a project using Turbopack:
next.config.ts
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
experimental: {
goRoutes: true,
},
};
export default nextConfig;
Then add a route.go file to handle GET /api/hello:
app/api/hello/route.go
package route
import (
"fmt"
"net/http"
)
func GET(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello from Go!")
}
Run next dev and open /api/hello to see Hello from Go!. When you edit the handler, Turbopack recompiles it automatically.
This new image optimization mode uses a combination of memory-safe image decoders, process isolation, and Linux seccomp sandboxing to reduce the risks associated with processing untrusted images.
Try it out today by enabling experimental.imgOptSafeMode in your Next.js config:
next.config.ts
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
experimental: {
imgOptSafeMode: true,
},
};
export default nextConfig;
This option may be ignored in production if your deployment platform provides its own image optimization service, such as on Vercel. In these cases, similar protections and mitigations are already provided by the deployment platform.