Nextjs Fundamentals · Deployment & Operations

Deploying a Node.js server

deployment targets

Deploying a Node.js server

Next.js can run almost anywhere, but the deployment target decides which features you get. The most capable target is a plain Node.js server.

Add build and start scripts to package.json:

{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  }
}

Then npm run build compiles the application and npm run start boots a server that supports every Next.js feature — Server Components, Server Actions, ISR, Cache Components, Proxy, and streaming.

Many managed platforms run exactly this server for you. You can also package it as a Docker image and run it on any container host, which supports all the same features.

For containers, Next.js offers a standalone output mode:

// next.config.js
module.exports = { output: 'standalone' };

next build then emits a minimal server.js and only the dependencies it actually needs, so the image stays small.

A static export, by contrast, produces files with no server at all, so it gives up the server-only features. Choose the target by the features you need, not by habit.

You are about to answer a short quiz on deployment targets.

  1. A Node.js deployment runs `next build` then `next start` and supports every Next.js feature.
  2. A Docker deployment supports fewer Next.js features than a Node.js server.
  3. To emit a minimal server bundle for containers, set output to ___ in next.config.js.
  4. output: 'standalone' emits only the runtime files and dependencies the server needs.
  5. A static export produces HTML, CSS, and JS with no ___ at all.