Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Next.js Quietly Adds Go-Powered Switchyard to Offload Network Layer from Node.js

Next.js merged an experimental Go-based front-end server called Switchyard to handle network connections and routing, offloading high-concurrency duties from Node.js while keeping React rendering in Node.js, mirroring a broader trend where companies like Resend migrate performance-critical paths to Go but retain Node.js for business logic.

On November 19, Next.js merged two key pull requests (https://github.com/vercel/next.js/pull/101695 and https://github.com/vercel/next.js/pull/102035) into its main branch, introducing a Go-written front-end server named Switchyard for the production next start command.

How Switchyard Works

Previously, a self-hosted Next.js application ran as a single Node.js process listening directly on a public port, handling network acceptance, routing, React server-side rendering, and business logic all together. With Switchyard enabled, the request path becomes two layers:

client ► Switchyard :3000 ► Node 127.0.0.1:<OS-chosen>
         (Go, child of Node)      router-server, unchanged

The Node.js process first binds a random local private port on 127.0.0.1, then spawns the Go-based Switchyard as a child process. Switchyard takes over the public port 3000. The two processes are lifecycle-bound via standard input/output: when Node exits it closes stdin so Switchyard can drain in-flight requests, and if Switchyard crashes unexpectedly, Node exits as well.

Go Gopher embracing Next.js logo while pushing Node.js logo aside
Go Gopher embracing Next.js logo while pushing Node.js logo aside

Experimental Status and Requirements

Switchyard is strictly opt-in and experimental. It requires the environment variable __NEXT_EXPERIMENTAL_SWITCHYARD=1 to activate. The Go binary is not yet shipped in the npm package; to try it locally you need Go 1.24+ installed and must set NEXT_BUILD_SWITCHYARD=1 during build, which produces a ~6 MB executable. Currently only Linux and macOS on amd64/arm64 are supported; Windows is not.

According to the PR description, this is only the first step. Switchyard currently just passes requests through to Node.js without making routing decisions. The long-term plan is to gradually move routing and other network-layer responsibilities from Node.js into Go, bringing the self-hosted next start architecture closer to Vercel's online proxy architecture.

Development is moving quickly. On the same day (Nov 19), a follow-up PR (https://github.com/vercel/next.js/pull/102101) registered route paths and workers with Switchyard. On Nov 24, telemetry for experimental.goRoutes was added. On Nov 25, author @jamiboym opened a series of PRs to align Switchyard's behavior with native next start on details like HTTP/1.0 connection closing, request header limits, and chunked transfer handling.

Why the Network Entry Layer Is Moving to Go Now

The article places Next.js's move alongside a recent production retrospective from email API provider Resend (https://resend.com/blog/migrating-our-email-api-to-go, Nov 12). Resend spent 7 weeks and ~140 PRs to migrate their core email-sending API from Node.js entirely to Go, achieving 100% production traffic cutover by October.

Resend's motivation was concrete: under bursty large-request-body loads, the Node.js event loop would stall because parsing and serializing large JSON payloads is synchronous CPU-intensive work in Node.js. Even requests that were ultimately rate-limited still had to go through parsing first, blocking the event loop and causing all subsequent requests to wait.

Diagram showing CPU-intensive requests blocking Node.js event loop
Diagram showing CPU-intensive requests blocking Node.js event loop

Resend shared 50% canary-phase metrics comparing identical task specs:

Single-email POST /emails median latency: 58 ms → 31 ms

Batch endpoint median latency: 149 ms → 74 ms

Per-request CPU consumption reduced ~62%

Peak required task count: 34 → 10

Memory per task: Node.js ~1.3 GB → Go ~180 MB

Memory usage comparison: Node.js ~1.3 GB vs Go ~180 MB per task
Memory usage comparison: Node.js ~1.3 GB vs Go ~180 MB per task

Go Is Strong, But Not a Full Node.js Replacement

The article cautions against reading these results as "Node.js is obsolete." Two important caveats from Resend's own account:

The p99 tail latency for POST /emails improved only ~16% (498 ms → 420 ms) because the dominant latency comes from waiting on external dependencies (S3, database), which language speed cannot fix.

To avoid breaking existing users, Resend had to manually re-implement Node.js's Buffer serialization rules and HTML-to-text edge-case behaviors in Go, and still had to scale up, tune S3 timeouts, and adjust Redis connection pools during rollout. The engineering cost of such a full rewrite is prohibitive for small teams.

Next.js's Switchyard takes a different, pragmatic approach: it does not aim to remove Node.js. React component rendering, Server Components, and the vast npm ecosystem remain firmly in Node.js. Switchyard simply stands at the door, taking over high-concurrency connection management, routing dispatch, and native Go routing — the "dirty work" — while Node.js continues to excel at business orchestration and full-stack frontend rendering.

Meanwhile, Node.js core recently merged experimental green threads ( node:green_threads) to address high-concurrency shortcomings, but ecosystem leaders are already adopting a more practical division of labor: let Go or Rust handle the network entry and heavy CPU computation, while Node.js continues to own business logic and frontend rendering. Each does what it's best at, which is far more productive than debating replacement.

References

[1] https://github.com/vercel/next.js/pull/101695

[2] https://github.com/vercel/next.js/pull/102035

[3] https://github.com/vercel/next.js/pull/102101

[4] https://resend.com/blog/migrating-our-email-api-to-go

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

PerformancearchitectureconcurrencyGoNode.jsNext.jsResendSwitchyard

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion