standalone output
A next.config setting that makes next build produce a self-contained folder with a minimal server.js and only the node_modules files it needs.
In more detail
The result lives in .next/standalone and runs with node server.js, which makes Docker images far smaller. public/ and .next/static are not copied in, so copy them yourself into the runner image.
Example
// next.config.ts
export default { output: 'standalone' };Related terms
- output file tracing — The build step where Next.js follows every import from your server code to find exactly which files are needed at runtime.
- server.js — The small generated Node.js server file in the standalone output that serves the whole app.
- .next directory — The folder where next build writes its output: compiled server code, static assets in .next/static and, if enabled, .next/standalone.
- multi-stage build — A Dockerfile with several FROM stages, where later stages copy only what they need from earlier ones.
Taught in
- Containerized Deployment: Multi-Stage Docker Builds — Next.js 15 & Modern App Router Architecture