Sulat.com / Writing on AIFriday, December 4, 2026
Enter →
Developer Tools/4 December 2026

A hands-on guide to Next.js Go routes

Next.js 16.5 adds experimental route.go files that run Go beside TypeScript. I ran them in dev, build and production and measured them against route.ts.

Black Next.js badge and cyan Go logo joined by a small bridge of cardboard boxes with one cyan box sliding across
Illustration: Sulat, featuring the Next.js and Go logos

At a glance

  • Next.js 16.5 adds experimental route.go files, so a route in the app directory can be written in Go with the standard net/http package.
  • On a four-core test machine a Go route served about 6,400 requests a second behind Node and about 13,800 with the Go server, against about 1,700 for the same TypeScript route.
  • A CPU-bound Go route was five times faster than its TypeScript twin, in line with Vercel's claim of more than five times less CPU time.
  • The Go server the release post recommends didn't start on the published 16.5.0 package because its binary is missing, so I built it from the v16.5.0 source.
  • Go routes need Turbopack and don't support static export, ISR or WebSocket upgrades, and a standalone build runs them without Go installed.

Next.js 16.5 lets you put a route.go file in the app directory and have Go answer the request. The Go team’s own account promoted it, which made it news for Go as well as for Next.js. I ran it in dev, build and production. Go routes work as described and use far less CPU than the same route in TypeScript. The faster Go server the release post promotes didn’t run on the published package until I built it from source.

What Vercel and the Go team announced

Vercel published Native Languages in Next.js on 2 December. It adds experimental support for Go through a new route.go convention, and starts rewriting the next start production server in Go. On 3 December the official Go account posted its approval, quoting Cameron Balahan, the group product manager for Go.

The Go team’s post about Next.js building more of itself on Go.

Go is built to be both productive and production-ready, and Vercel building more of Next.js on Go reflects exactly that: fast builds, simple code, and a comprehensive standard library in development; reliable, efficient, high-performance binaries in production.

Cameron Balahan, Group Product Manager, Go

Vercel’s argument is that coding agents have removed the cost of working in a second language. It says deployments driven by coding agents grew from 3% of Vercel’s total at the start of 2026 to 60% by November, and it points to Anthropic’s move of its Messages API from Python to Rust as the same pattern. The post claims two measured results. Cumulative active CPU time across 200 requests of a production workload fell from 23.412 seconds with route.ts to 4.546 seconds with route.go. And in early benchmarks, letting the new Go server call a Go route directly lifted throughput from 5,956 to 25,818 requests a second, cut p99 latency by 59% and cut CPU per request by 37%.

How it works

A route is a Go package called route with top-level functions named after HTTP methods, each taking the standard net/http writer and request. In next dev your local Go toolchain compiles each route on its own. In next build every route.go directory is compiled into one shared executable, so production runs a single compiled process and doesn’t need Go installed.

Flow diagram: browser request to Go-based next start, which sends route.go to Go and pages and route.ts to Node.js
With the Go server, Go routes skip Node entirely. Everything else still goes through it. Illustration: Sulat

The Go-based server is the part that matters for speed. Without it, Node.js still receives every request and forwards Go routes onward. With --experimental-new-server, Go owns the public port, sends route.go requests straight to Go, and passes React rendering and route.ts handlers to Node. The post says those Node-served requests still take an extra hop for now.

What I ran

Everything ran on one cloud machine with four Intel Xeon cores at 2.3 GHz under KVM, 16 GB of memory, a 252 GB disk and Ubuntu 24.04 on kernel 6.18. Go was 1.24.7, Node.js 22.23.5 and Next.js 16.5.0 with Turbopack. The load generator, autocannon 9.0.0, ran on the same four cores as the server, so absolute figures are lower than a dedicated rig would give.

StepWhat I ranResult
DevGET, POST and DELETE on a dynamic Go route, a streamed route, edits and a deliberate errorWorked, DELETE returned 405
Buildnext build with four Go routes and two TypeScript routesOne 8.6 MB Go binary
Startnext start with and without the Go serverGo server needed a source build
BenchmarkHello route and a CPU-bound route, Go against TypeScriptGo 3.8x to 8.6x and 5x faster
StandaloneOutput standalone, run with Go off the PATHGo routes still answered
LimitsWebpack build, static exportBoth refused
What I ran against Next.js 16.5.0.

The full guide

1. Check Go and create the project

Next.js needs Go 1.24 or newer on the PATH for next dev and next build. My machine already had 1.24.7, so nothing was downloaded. Apps without Go routes don’t need Go at all.

Code
go version
mkdir nx && cd nx && npm init -y
npm i [email protected] react react-dom typescript @types/node @types/react

2. Turn the flag on

Go routes are off until you enable experimental.goRoutes. They need Turbopack, which is the default in 16.5.

Code
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  experimental: {
    goRoutes: true,
  },
};

export default nextConfig;

The first next dev also created an AGENTS.md in the project telling coding agents to read the docs bundled in node_modules, which fits Vercel’s agent-first pitch. You can turn it off with agentRules: false.

3. Write a Go route

This is the example from the release post, unchanged, at app/api/hello/route.go.

Code
package route

import (
  "encoding/json"
  "net/http"
)

func GET(w http.ResponseWriter, r *http.Request) {
  w.Header().Set("Content-Type", "application/json")
  json.NewEncoder(w).Encode(map[string]string{"message": "Hello from Go!"})
}

I added a TypeScript route at app/api/ts-hello/route.ts beside it for comparison.

Code
export async function GET() {
  return Response.json({ message: "Hello from TypeScript!" });
}

4. Add methods and a dynamic segment

A second Go route at app/api/items/[id]/route.go reads the segment with r.PathValue and handles two methods. Any method you don’t declare gets a 405.

Code
package route

import (
  "encoding/json"
  "net/http"
)

func GET(w http.ResponseWriter, r *http.Request) {
  w.Header().Set("Content-Type", "application/json")
  json.NewEncoder(w).Encode(map[string]string{"id": r.PathValue("id"), "runtime": "go"})
}

func POST(w http.ResponseWriter, r *http.Request) {
  var body map[string]any
  json.NewDecoder(r.Body).Decode(&body)
  w.WriteHeader(201)
  json.NewEncoder(w).Encode(map[string]any{"id": r.PathValue("id"), "received": body})
}

5. Stream a response

The docs say streaming uses http.Flusher and that r.Context().Done() signals a client disconnect. This route, at app/api/stream/route.go, sends three chunks half a second apart.

Code
package route

import (
  "fmt"
  "net/http"
  "time"
)

func GET(w http.ResponseWriter, r *http.Request) {
  f := w.(http.Flusher)
  w.Header().Set("Content-Type", "text/plain")
  for i := 1; i <= 3; i++ {
    select {
    case <-r.Context().Done():
      return
    case <-time.After(500 * time.Millisecond):
    }
    fmt.Fprintf(w, "chunk %d\n", i)
    f.Flush()
  }
}

6. Run it in dev

Code
npx next dev -p 3100
curl -i localhost:3100/api/hello
curl localhost:3100/api/items/42
curl -X POST -H 'content-type: application/json' -d '{"a":1}' localhost:3100/api/items/42
curl -i -X DELETE localhost:3100/api/items/42
curl -N localhost:3100/api/stream
Terminal: curl requests to Go routes in next dev, GET, POST, a 405 on DELETE, a TypeScript route and a streamed response
Go and TypeScript routes side by side in dev. The stream arrives in three chunks half a second apart.

The first request to a Go route took about a second while Next.js compiled it, and later ones took milliseconds. After I edited the file, the next request took about 0.6 seconds and returned the new text.

7. Break it on purpose

I added a line of invalid Go to route.go. The route returned HTTP 500, the terminal printed the compiler error, and the browser showed the usual Next.js error overlay with the file, line and column. Removing the line brought the route back with no restart.

Next.js 16.5.0 error overlay: Unable to compile route.go with the Go syntax error and line number
A Go syntax error shows up in the same overlay as a TypeScript one.
Terminal: route.go edit answered after save, a syntax error returns HTTP 500, removing it returns HTTP 200
Edit, error and recovery in one dev session.

8. Build and start

Code
npx next build
ls -la .next/server/go-routes-*
npx next start -p 3200

The build compiled in about two seconds and produced one 8.6 MB executable, .next/server/go-routes-<hash>, for all four Go routes. Next.js lists them as dynamic routes beside the TypeScript one. Running next start starts that binary next to the Node server.

9. Try the Go server

The release post says to pass --experimental-new-server. On the published 16.5.0 package for Linux x64 it didn’t start.

Code
npx next start -p 3200 --experimental-new-server
Terminal: next start --experimental-new-server refuses to run because the Switchyard binary is missing from 16.5.0
The command the post recommends, run on the published 16.5.0 package.

The package carries only a targets.json where the Go server binary should be. The 16.6.0-canary.2 tarball is the same. The error says to set __NEXT_EXPERIMENTAL_SWITCHYARD_BINARY to a build made with go build in packages/next/src/server/switchyard. That directory is in the open-source repository, so I fetched it at the v16.5.0 tag and built it with Go 1.24.7. It compiled in about ten seconds into a 10.8 MB executable.

Code
git clone --depth 1 --filter=blob:none --sparse --branch v16.5.0 https://github.com/vercel/next.js
cd next.js && git sparse-checkout set packages/next/src/server/switchyard
cd packages/next/src/server/switchyard && go build -o /tmp/switchyard-linux-amd64 .

__NEXT_EXPERIMENTAL_SWITCHYARD_BINARY=/tmp/switchyard-linux-amd64 \
  npx next start -p 3200 --experimental-new-server

With that binary the server started, served Go routes, TypeScript routes and the home page, and streamed correctly. The numbers below for the Go server come from this source build. Vercel’s post doesn’t say which build its figures come from.

10. Ship it without Go

With output: "standalone" the build copies the Go binary into .next/standalone with its permissions. I started the standalone server in a shell where go wasn’t on the PATH.

Terminal: Go not found on PATH, standalone build still answers two Go routes with the compiled binary
The standalone folder is 53 MB and serves both Go routes with no Go installed.

What I measured

I used autocannon with 64 connections for 10 seconds, three runs per case, and took the median. The route returns a one-line JSON message in both languages. A second test used four connections against a CPU-bound route that counts primes below two million with a sieve, written the same way in both languages. The Go version is at app/api/primes-go/route.go and the TypeScript one at app/api/primes-ts/route.ts.

Code
package route

import (
  "encoding/json"
  "net/http"
)

func GET(w http.ResponseWriter, r *http.Request) {
  const n = 2_000_000
  sieve := make([]bool, n+1)
  count := 0
  for i := 2; i <= n; i++ {
    if !sieve[i] {
      count++
      for j := i * i; j <= n; j += i {
        sieve[j] = true
      }
    }
  }
  w.Header().Set("Content-Type", "application/json")
  json.NewEncoder(w).Encode(map[string]any{"limit": n, "primes": count, "runtime": "go"})
}
Code
export async function GET() {
  const n = 2_000_000;
  const sieve = new Uint8Array(n + 1);
  let count = 0;
  for (let i = 2; i <= n; i++) {
    if (!sieve[i]) {
      count++;
      for (let j = i * i; j <= n; j += i) sieve[j] = 1;
    }
  }
  return Response.json({ limit: n, primes: count, runtime: "node" });
}
Code
autocannon -c 64 -d 10 -j localhost:3200/api/hello
autocannon -c 64 -d 10 -j localhost:3200/api/ts-hello
autocannon -c 4 -d 10 -j localhost:3200/api/primes-go
autocannon -c 4 -d 10 -j localhost:3200/api/primes-ts
Terminal: autocannon results for route.go and route.ts, hello route and a CPU-bound prime sieve
Median of three runs, with the load generator on the same four cores. There were no failed requests.
Bar chart: route.ts 1,612 requests a second, route.go behind Node 6,428, route.go direct 13,816
Putting the Go server in front doubled the Go route’s throughput. Illustration: Sulat

Behind Node, the Go route handled about 6,400 requests a second against about 1,700 for the TypeScript route, and p99 latency was 20 ms against 62 ms. With the Go server in front, the Go route reached about 13,800 requests a second with a 13 ms p99, while the TypeScript route stayed near 1,600 because it still runs on Node. That is 8.6 times the TypeScript route on the hello-world case.

Vercel reports 4.3 times for the same switch and I got 2.1 times. Its absolute numbers are higher too, and my load generator shared the four cores with the server. A hello-world route is also the best case for any server in front of a handler.

The CPU-bound route is the fairer test of the language. Go served 444 requests a second against 89 for TypeScript, a five-fold gap, with p99 latency of 19 ms against 87 ms. That agrees with Vercel’s claim of more than five times less CPU time, although I measured throughput on a different workload and not CPU seconds.

What doesn’t work yet

Checklist: route.go supports net/http, streaming and no Go in production; no webpack, export, ISR or WebSockets
Webpack and static export are refused outright. Illustration: Sulat

I confirmed two limits myself. next build --webpack stops with route.go requires Turbopack; remove --webpack. Setting output: "export" fails the config check with `route.go` and `proxy.go` do not support `output: "export"`.

The docs list the rest, which I didn’t test: Go routes always run dynamically and don’t support ISR or generateStaticParams, WebSocket upgrades and HTTP trailers are unsupported, builds target the build machine’s operating system and architecture with CGO off, dependencies must already be in the Go module cache, runtime file reads aren’t traced so assets need go:embed, and Go handlers read the process environment rather than values inlined from next.config. React rendering and Server Actions stay on Node.js.

One more detail from the package. The release post’s source has a proxy.go section commented out, but the package already ships a next/go/proxy module and the config check names proxy.go. I didn’t run it, and the post doesn’t announce it.

Where it sits

Next.js isn’t alone in moving server work into Go and Rust, but it’s doing it differently. Laravel went all the way: Laravel Go is a whole framework in Go, and in my tests it served routes 28 to 69 times faster than the PHP version. Laravel Cloud now runs Go and Rust apps too, and Spatie has ported 44 of its packages to Go. Next.js keeps React, TypeScript and Node.js as the core and lets one route at a time move to Go, so you don’t rewrite the app to get the speed.

The pattern behind it is the one Vercel cites. Anthropic moved its Messages API from Python to Rust and reports about 70% less CPU per request and about 20% lower median time to first token. Inside Next.js, the release post says Turbopack is already Rust, TypeScript 7’s Go-based type checker arrived in 16.3, and Rust-backed React Compiler work arrived in 16.4. It also says it plans to add more native languages, with Rust named as an example.

The gap is hosting. The post says the Adapters API contract for native runtimes hasn’t been decided and will be settled before route.go goes stable. Today it works with next start and standalone builds, and a host that wants to run Go routes needs that contract first.

Before you use it

  1. Keep it to jobs that earn it: webhook receivers, streaming proxies and CPU-heavy handlers. Pages and Server Actions stay on Node.js.
  2. Install Go 1.24 or newer on the build machine and match its operating system and architecture to production.
  3. Use Turbopack and avoid static export, ISR and WebSockets on those routes.
  4. Pin [email protected] and expect the API to change, since the whole feature is experimental.
  5. Don’t depend on --experimental-new-server until the Go server ships in the package.

Sources