Minimal self-contained server bundle for containers.
Skip to solutionKEEP THE
mediumSystem Design
What is the output: 'standalone' build in Next.js and when do you use it?
85 views
01
Understand the problem
nextjsstandalonedockerdeployment
02
Attempt it yourself
Sketch your approach before reading the solution — that's what interviews test.
Nudge consolestandby
Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.
03
Study the solution
output: 'standalone' produces a minimal folder with the server and only the node_modules it needs, so Docker images are small and don't require installing all dependencies. Use it for self-hosted/containerized deployments to cut image size and cold starts.
Solution ready — 2 min read
Classified // press E to declassify
04
Read the code
Standalone in a Dockerfile
# next.config.js → { output: 'standalone' }
# runtime stage:
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static # must copy separately
COPY --from=build /app/public ./public
CMD ["node", "server.js"] # no node_modules install needed05
Join the discussion
Discussion (0)
Sign in to join the discussion.
No responses yet. Be the first to share what you think.
Transmission complete // awaiting log
KEEP THE
STREAK ALIVE.
Dossier 69 of 95 decoded in the Next.js track. One more won't hurt.