{"slug": "next-js-now-has-experimental-native-go-support", "title": "Next.js now has experimental native Go support", "summary": "Vercel shipped Next.js 16.5 with experimental native Go support for Route Handlers, letting developers write a route.go file alongside TypeScript routes. The release also makes Turbopack cold compilation roughly 4.2× faster with 38% less memory and a 14% smaller on-disk cache, and lets functions marked 'use cache: remote' reuse cached entries across deployments when their code and dependencies are unchanged. Vercel benchmarked compilation of its dashboard on a 30-core, 60 GB build machine, and across five other Vercel apps including nextjs.org measured peak memory reductions of 6%-27% and disk cache size cuts of up to 23%.", "body_md": "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.\n\nHere's what's new in 16.5:\n\nFaster 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.\n\nCross-deployment caching. Functions marked with 'use cache: remote' can read cached entries from a previous deployment when their code and dependencies haven't changed.\n\nPer-link navigation prefetching. Setting prefetch=\"navigation\" lets an individual <Link> prefetch cached content that navigation() would otherwise defer until click.\n\nAutomatically 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.\n\nSafe 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.\n\nNext.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.\n\nUpgrade today with a coding agent, or install next@latest directly:\n\nThe 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.\n\nTo support these new workflows, we've focused on improving Turbopack's build performance in a few key areas:\n\nBetter utilization of all available CPU cores during builds\n\nEnsuring applications can scale to thousands of routes\n\nReducing memory and disk space overheads to keep applications inside build container limits\n\nTo measure the impact of this work, we benchmarked compilation of Vercel's dashboard on a 30-core, 60 GB build machine.\n\nCompile 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.\n\nFull production builds also benefited from these changes, with cold builds cutting their time in half:\n\nWe also optimized Turbopack to use memory and disk space more efficiently:\n\nAcross 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%.\n\nPreviously, 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.\n\nFor example, say you had a function like getProduct:\n\napp/catalog/data.ts\n\n``` js\nimport { db } from \"@/lib/db\";\n \nexport async function getProduct(id: string) {\n  \"use cache: remote\";\n  return db.product.findUnique({ where: { id } });\n}\n```\n\nEven 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.\n\nNext.js 16.5 fixes this. Functions using 'use cache: remote' now have the ability to reuse their entries across deployments.\n\nIn 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.\n\nIf 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.\n\nEntries 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.\n\nWhen 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).\n\nThis 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.\n\nIn Next.js 16.5, you can use the new --analyze option to generate a report during your normal production builds:\n\nTerminal\n\n```\nnpx next build --analyze\n```\n\nThis 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.\n\nNext.js 16.4 introduced a new experimental garbage collector that cleaned up unused compilation work during long dev sessions via the turbopackGc flag.\n\nIn 16.5, we're enabling this feature by default for all apps.\n\nWith 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.\n\nRequest 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 loading, data fetching, and rendering took.\n\nYou 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.\n\nIn 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.\n\nThe example from the 16.4 blog post showed using it to exclude an email's replies from being rendered during the Inbox's prefetches:\n\n``` js\nimport { navigation } from 'next/cache';\n \nasync function Message({ id }) {\n  const message = await getMessage(id);\n \n  return (\n    <>\n      <p>{message.subject}</p>\n      <div>{message.body}</div>\n \n      <Suspense fallback={<Spinner />}>\n        <Thread id={id} />\n      </Suspense>\n    </>\n  );\n}\n \nasync function Thread({ id }) {\n  await navigation(); // Exclude Threads from being prefetched\n  const thread = await getThread(id);\n \n  return (\n    <>\n      {thread.map((message) => (\n        <div key={message.id}>{message.body}</div>\n      ))}\n    </>\n  );\n}\n```\n\nThis let the Inbox render prefetched links, without having to fully load every single message's thread:\n\n``` js\n<nav>\n  {messages.map((message) => (\n    <Link\n      href={`/message/${message.id}`}\n      key={message.id}\n      prefetch\n    >\n      {message.subject}\n    </Link>\n  ))}\n</nav>\n```\n\nBut 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().\n\nIn 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.\n\nIn 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():\n\n```\n<Link href=\"https://nextjs.org/message/42\" prefetch=\"navigation\">\n  Next unread\n</Link>\n```\n\nOnce \"Next unread\" enters the viewport, Next.js prefetches the full thread, so all the content is instantly ready by the time the user clicks.\n\nnext 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:\n\nTerminal\n\n```\nnpx next@canary upgrade --ci\n```\n\nThe 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.\n\nOnce 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.\n\nYou 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.\n\nNext.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.\n\nTo try a Go Route Handler, install Go 1.24 or later and enable goRoutes in a project using Turbopack:\n\nnext.config.ts\n\n``` python\nimport type { NextConfig } from \"next\";\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    goRoutes: true,\n  },\n};\n \nexport default nextConfig;\n```\n\nThen add a route.go file to handle GET /api/hello:\n\napp/api/hello/route.go\n\n```\npackage route\n \nimport (\n    \"fmt\"\n    \"net/http\"\n)\n \nfunc GET(w http.ResponseWriter, r *http.Request) {\n    fmt.Fprintln(w, \"Hello from Go!\")\n}\n```\n\nRun next dev and open /api/hello to see Hello from Go!. When you edit the handler, Turbopack recompiles it automatically.\n\nThis 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.\n\nTry it out today by enabling experimental.imgOptSafeMode in your Next.js config:\n\nnext.config.ts\n\n``` python\nimport type { NextConfig } from \"next\";\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    imgOptSafeMode: true,\n  },\n};\n \nexport default nextConfig;\n```\n\nThis 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.", "url": "https://wpnews.pro/news/next-js-now-has-experimental-native-go-support", "canonical_source": "https://nextjs.org/blog/next-16-5", "published_at": "2026-12-03 18:37:33+00:00", "updated_at": "2026-12-03 18:48:56.297633+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents"], "entities": ["Vercel", "Next.js", "Next.js 16.5", "Turbopack", "Go", "nextjs.org"], "also_reported_by": [], "takeaway": "Next.js 16.5 adds experimental Go Route Handlers via a route.go file and lets 'use cache: remote' functions reuse cache entries across deployments when their code and dependencies are unchanged, with Turbopack cold builds ~4.2× faster at 38% less memory.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/next-js-now-has-experimental-native-go-support", "markdown": "https://wpnews.pro/news/next-js-now-has-experimental-native-go-support.md", "text": "https://wpnews.pro/news/next-js-now-has-experimental-native-go-support.txt", "jsonld": "https://wpnews.pro/news/next-js-now-has-experimental-native-go-support.jsonld"}}