How it works
The explanation, with examples you can run.
A Node.js server
{ "scripts": { "build": "next build", "start": "next start" } }next start serves prerendered shells, streams dynamic holes, runs Server Actions, Route Handlers and Proxy, and optimises images. For containers, output: "standalone" copies only the files and node_modules the server needs into .next/standalone, which keeps images small. Put a reverse proxy such as nginx in front: it deals with slow clients and malformed requests better than the app server.
A static export
// next.config.tsexport default { output: "export" }next build then writes out/ with one HTML file per route, which any static host or bucket can serve. Not available: dynamic routes without generateStaticParams, cookies and headers, rewrites, redirects, Proxy, Server Actions, ISR, draft mode, and image optimisation with the default loader (use a custom loader or unoptimized). It is a good start for a marketing site or an SPA, and you can switch to a server later.
Many instances
When you scale out, each copy of the server starts with its own state:
- Cache: the default
use cachestore is in memory per instance, and the ISR page cache is on local disk. ConfigurecacheHandlers(foruse cache: remote) orcacheHandlerwith Redis or similar so all instances share entries and tag invalidations. - Server Action keys: closure encryption uses a key generated per build. Build once and deploy the same artifact everywhere, or set
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY. - Version skew: during a rolling deploy, a browser may hold an old page and talk to a new server. Setting
deploymentIdlets Next.js detect the mismatch and do a full reload instead of a broken client navigation.
Runtimes
Next.js has two server runtimes. Node.js is the default and supports everything. The Edge runtime, a subset of Web APIs that once promised faster cold starts, is deprecated in current Next.js: remove export const runtime = "edge" from routes. Proxy runs on Node.js, and Cache Components doesn't accept the runtime option at all. Vercel likewise recommends migrating from Edge to Node.js functions, and its docs note that from Next.js 16.3 routes and pages run on Node.js there regardless of the setting. On serverless platforms in general, remember that function instances are short-lived: a cache that works on your laptop may barely hit in production unless it is shared.
Check yourself
3 questions. Get them all right to finish this topic.
0 of 3 right so far. Get all three to finish this topic.