---
title: Next.js 16.5
description: Next.js 16.5 brings faster Turbopack builds, cross-deployment caching, Go Route Handlers, and more.
url: "https://nextjs.org/blog/next-16-5"
docs_index: /docs/llms.txt
publishedAt: December 2nd 2026
---



Next.js 16.5 is now available!

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.**](#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.**](#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.
- [**Bundle reports can now be generated during builds.**](#bundle-reports-can-now-be-generated-during-builds) Running `next build --analyze` generates a bundle report directly from your production build's compilation step.
- [**Automatic disk cache cleanup.**](#automatic-disk-cache-cleanup) Turbopack's garbage collector is now enabled by default.
- [**Per-link navigation prefetching.**](#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.**](#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.**](#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**](#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:

```bash filename="Terminal"
# Upgrade with a coding agent
npx next@canary upgrade --agent=latest

# Or upgrade manually
npm install next@latest
```

## Faster Turbopack builds

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.

<ComparisonChart
  title="Compile times of vercel.com."
  ariaLabel="Compile time with a cold and warm cache for Next.js 16.4.6 and 16.5.0. Lower is better."
  groups={[
    {
      label: "Cold cache",
      improvement: "~4.2× faster",
      ariaLabel: "Compilation, cold cache",
      wideLabels: true,
      bars: [
        {
          label: "16.4.6",
          value: "183s",
          percentage: 100,
          ariaLabel: "Next.js 16.4.6: 183 seconds",
        },
        {
          label: "16.5.0",
          value: "44s",
          percentage: 24.0,
          ariaLabel: "Next.js 16.5.0: 44 seconds",
        },
      ],
    },
    {
      label: "Warm cache",
      improvement: "~2.7× faster",
      ariaLabel: "Compilation, warm cache",
      wideLabels: true,
      bars: [
        {
          label: "16.4.6",
          value: "12.0s",
          percentage: 6.6,
          ariaLabel: "Next.js 16.4.6: 12.0 seconds",
        },
        {
          label: "16.5.0",
          value: "4.4s",
          percentage: 2.4,
          ariaLabel: "Next.js 16.5.0: 4.4 seconds",
        },
      ],
    },
  ]}
/>

Full production builds also benefited from these changes, with cold builds cutting their time in half:

<ComparisonChart
  title="Full production build times of vercel.com."
  ariaLabel="Total build time with a cold and warm cache for Next.js 16.4.6 and 16.5.0. Lower is better."
  groups={[
    {
      label: "Cold cache",
      improvement: "~2.0× faster",
      ariaLabel: "Full production build, cold cache",
      wideLabels: true,
      bars: [
        {
          label: "16.4.6",
          value: "325s",
          percentage: 100,
          ariaLabel: "Next.js 16.4.6: 325 seconds",
        },
        {
          label: "16.5.0",
          value: "159s",
          percentage: 48.9,
          ariaLabel: "Next.js 16.5.0: 159 seconds",
        },
      ],
    },
    {
      label: "Warm cache",
      improvement: "~1.3× faster",
      ariaLabel: "Full production build, warm cache",
      wideLabels: true,
      bars: [
        {
          label: "16.4.6",
          value: "134s",
          percentage: 41.2,
          ariaLabel: "Next.js 16.4.6: 134 seconds",
        },
        {
          label: "16.5.0",
          value: "107s",
          percentage: 32.9,
          ariaLabel: "Next.js 16.5.0: 107 seconds",
        },
      ],
    },
  ]}
/>

We also optimized Turbopack to use memory and disk space more efficiently:

<ComparisonChart
  id="memory-and-disk-use"
  title="Memory and disk usage during builds of vercel.com."
  ariaLabel="Peak memory while compiling and on-disk cache size for Next.js 16.4.6 and 16.5.0. Lower is better."
  groups={[
    {
      label: "Peak memory while compiling, cold cache",
      improvement: "38% less",
      ariaLabel: "Cold cache, peak memory while compiling",
      wideLabels: true,
      bars: [
        {
          label: "16.4.6",
          value: "24.1 GB",
          percentage: 100,
          ariaLabel: "Next.js 16.4.6: 24.1 gigabytes",
        },
        {
          label: "16.5.0",
          value: "15.0 GB",
          percentage: 62.1,
          ariaLabel: "Next.js 16.5.0: 15.0 gigabytes",
        },
      ],
    },
    {
      label: "Peak memory while compiling, warm cache",
      improvement: "28% less",
      ariaLabel: "Warm cache, peak memory while compiling",
      wideLabels: true,
      bars: [
        {
          label: "16.4.6",
          value: "8.2 GB",
          percentage: 100,
          ariaLabel: "Next.js 16.4.6: 8.2 gigabytes",
        },
        {
          label: "16.5.0",
          value: "5.9 GB",
          percentage: 72.2,
          ariaLabel: "Next.js 16.5.0: 5.9 gigabytes",
        },
      ],
    },
    {
      label: "Cache size on disk",
      improvement: "14% smaller",
      ariaLabel: "On-disk cache size after a cold build",
      wideLabels: true,
      bars: [
        {
          label: "16.4.6",
          value: "2.96 GB",
          percentage: 100,
          ariaLabel: "Next.js 16.4.6: 2.96 gigabytes",
        },
        {
          label: "16.5.0",
          value: "2.56 GB",
          percentage: 86.5,
          ariaLabel: "Next.js 16.5.0: 2.56 gigabytes",
        },
      ],
    },
  ]}
/>

Across five other Vercel apps we benchmarked, including [nextjs.org](https://nextjs.org/), we saw reductions in peak memory by 6%-27% and disk cache sizes by up to 23%.

## Cross-deployment caching

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`:

```ts {4} filename="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)`.

Learn more about [the `use cache: remote` directive](/docs/app/api-reference/directives/use-cache-remote) and [using it with Vercel's Runtime Cache](https://vercel.com/docs/runtime-cache#using-use-cache:-remote).

## Bundle reports can now be generated during builds

The Next.js Bundle Analyzer helps you optimize your application's bundle sizes by making it easy to track down large dependencies.

Previously, you could [generate a bundle report to disk](/docs/app/guides/package-bundling#step-4-write-output-to-disk-for-sharing-or-diffing) by running

```bash filename="Terminal"
npx next analyze --output
```

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:

```bash filename="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.

Learn how to [trace a module's imports in the Bundle Analyzer](/docs/app/guides/package-bundling#step-3-trace-modules-with-import-chains).

## Automatic disk cache cleanup

Next.js 16.4 introduced a [new experimental garbage collector](/blog/next-16-4#disk-cache-cleanup) 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.

Learn more about [configuring Turbopack's cache cleanup](/docs/app/api-reference/config/next-config-js/turbopackGc).

## Per-link navigation prefetching

In Next.js 16.4, we released the `navigation()` API. You can use this API to [exclude content from a prefetch](/blog/next-16-4#excluding-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:

```jsx {1,19}
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:

```tsx {6}
<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()`:

```tsx {1}
<Link href="/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.

Learn more about [prefetching deferred content for a likely navigation](/docs/app/api-reference/functions/navigation#prefetching-deferred-content-for-a-likely-navigation).

## Automatically upgrade your app in CI

`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:

```bash filename="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](https://vercel.com/docs/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.

Learn more about [running scheduled upgrades on GitHub](/docs/app/guides/upgrading/agent-upgrade#run-scheduled-upgrades-on-github).

## Experimental features

### Go Route Handlers

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:

```ts filename="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`:

```go filename="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.

To learn more, read our latest post on [Native Languages in Next.js](/blog/native-languages-in-nextjs).

### Safe mode for image optimization

As we recently discussed in [our blog post about securing Next.js](/blog/how-were-using-ai-to-make-nextjs-more-secure#replacing-vulnerable-dependencies), we've been working on [an alternative implementation](https://github.com/vercel-labs/next-safe-image-optimization) of image optimization for Next.js.

This new image optimization mode uses a combination of memory-safe image decoders, process isolation, and Linux [seccomp](https://en.wikipedia.org/wiki/Seccomp) sandboxing to reduce the risks associated with processing untrusted images.

Try it out today by enabling `experimental.imgOptSafeMode` in your Next.js config:

```ts filename="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](https://vercel.com/docs/image-optimization). In these cases, similar protections and mitigations are already provided by the deployment platform.

## Feedback and community

We hope you're excited to try out Next.js 16.5!

Let your agent upgrade your app with our CLI command:

```bash filename="Terminal"
npx next@canary upgrade --agent=latest
```

or upgrade yourself:

```bash filename="Terminal"
npm install next@latest
```

And share your feedback to help shape the future of Next.js:

- [GitHub Discussions](https://github.com/vercel/next.js/discussions)
- [GitHub Issues](https://github.com/vercel/next.js/issues)
- [Discord Community](https://nextjs.org/discord)

## Contributors

Next.js is the result of the combined work of thousands of individual developers. This release was brought to you by:

- The **Next.js** team: [Andrew](https://github.com/acdlite), [Aurora](https://github.com/aurorascharff), [Dan](https://github.com/gaearon), [Jamiboy](https://github.com/jamiboym), [Jan](https://github.com/kassens), [Janka](https://github.com/lubieowoce), [Jiwon](https://github.com/devjiwonchoi), [Joseph](https://github.com/icyJoseph), [Josh](https://github.com/gnoff), [Pete](https://github.com/petehunt), [Sam](https://github.com/samselikoff), and [Tim](https://github.com/timneutkens).
- The **Turbopack** team: [Andrew](https://github.com/andrewimm), [Benjamin](https://github.com/bgw), [Jimmy](https://github.com/jimmyhmiller), [Luke](https://github.com/lukesandberg), [Niklas](https://github.com/mischnic), [Tobias](https://github.com/sokra), and [Will](https://github.com/wbinnssmith).

Huge thanks to @unstubbable, @eps1lon, @gaojude, @DavidIlie, @styfle, @deveshasawa28, @kakadiadarpan, @adityareddy-dev, @abhayymishraa, @blz-ea, @franpeza, @awss1i, @JannikZed, @dxdc, @mugi-uno, @leejpsd, @sabrinaluo, @kxrn-gupta, @yousefdawood7, @tobiaslins, @Aryan9891, @koreahghg, @zydo, @digasic, @huozhi, @arnaud-coral, @skrabe, @namtran1812, @chadhietala, @smaeda-ks, @vctqs1, @fireairforce, @shootaroo, @linyiru, @fediev, @robsimmons, @Rezakarimzadeh98, @codeandcore, @ShakilUrRehman21, @swarnava, @sleitor, @0badran, @DominikKoniarz, @zhengdaodeguL, @hyungjikim, and @ali-vercel for helping!
