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:
Standalone output
To produce a self-contained deployment artifact, setoutput: 'standalone' in next.config.js:
next.config.js
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
Build specific routes
CPU profiling
build-main-*— main orchestration processbuild-turbopack-*— Turbopack compilation worker
build-main-*— main orchestration processbuild-webpack-client-*— client bundle workerbuild-webpack-server-*— server bundle workerbuild-webpack-edge-server-*— edge runtime worker
