Skip to main content
next build creates an optimized production build of your application. The output shows a summary of each route:

Usage

Options

string
The directory containing the Next.js application. Defaults to the current working directory.
boolean
Force Turbopack (the default bundler). Also available as --turbo.
boolean
Build using Webpack instead of the default Turbopack.
boolean
Enable verbose build output. Shows rewrites, redirects, and headers configuration.
boolean
Enable production React profiling. Adds a small overhead.
boolean
Disable linting during the build.
boolean
Disable name mangling. Reduces performance; use only for debugging.
boolean
Build only App Router routes, skipping Pages Router routes.
string
default:"default"
Use an experimental build mode. Choices: 'compile', 'generate', 'default'.
boolean
Analyze bundle output using the bundle explorer. Only compatible with the Turbopack bundler.
boolean
Enable memory profiling features to help debug memory consumption during the build.
string
Report a subset of the debugging trace to a remote HTTP URL. Includes sensitive data.
boolean
Use Node.js native TypeScript resolution for next.config.ts or next.config.mts.
boolean
Debug prerender errors in a development-like build. Do not deploy builds produced with this flag.
string
Build only specific routes (comma-separated file paths or globs). Useful for faster targeted debugging.
boolean
Enable CPU profiling via V8’s inspector. Profiles are saved to .next/cpu-profiles/ on process exit.
boolean
Show all available options.

Build output analysis

The build output shows route types and sizes. To analyze bundle composition in detail, use the --experimental-analyze flag with Turbopack:
This runs a Turbopack build and opens an interactive bundle explorer in the browser.

Standalone output

To produce a self-contained deployment artifact, set output: 'standalone' in next.config.js:
next.config.js
After running next build, copy static assets and start the server:

Build traces

Next.js generates .nft.json trace files in .next/ that list all files required by each route. These are used by output: 'standalone' to create a minimal deployment bundle.

Examples

Debug prerender errors

This disables minification, enables server source maps, and continues past the first prerender error to surface all issues at once.
Do not deploy builds created with --debug-prerender—they may have reduced performance.

Build specific routes

CPU profiling

For Turbopack builds, profiles are named:
  • build-main-* — main orchestration process
  • build-turbopack-* — Turbopack compilation worker
For Webpack builds:
  • build-main-* — main orchestration process
  • build-webpack-client-* — client bundle worker
  • build-webpack-server-* — server bundle worker
  • build-webpack-edge-server-* — edge runtime worker

Version history