next build creates an optimized production build of your application. The output shows a summary of each route:
Usage
Options
The directory containing the Next.js application. Defaults to the current working directory.
Force Turbopack (the default bundler). Also available as
--turbo.Build using Webpack instead of the default Turbopack.
Enable verbose build output. Shows rewrites, redirects, and headers configuration.
Enable production React profiling. Adds a small overhead.
Disable linting during the build.
Disable name mangling. Reduces performance; use only for debugging.
Build only App Router routes, skipping Pages Router routes.
Use an experimental build mode. Choices:
'compile', 'generate', 'default'.Analyze bundle output using the bundle explorer. Only compatible with the Turbopack bundler.
Enable memory profiling features to help debug memory consumption during the build.
Report a subset of the debugging trace to a remote HTTP URL. Includes sensitive data.
Use Node.js native TypeScript resolution for
next.config.ts or next.config.mts.Debug prerender errors in a development-like build. Do not deploy builds produced with this flag.
Build only specific routes (comma-separated file paths or globs). Useful for faster targeted debugging.
Enable CPU profiling via V8’s inspector. Profiles are saved to
.next/cpu-profiles/ on process exit.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
Version history
| Version | Changes |
|---|---|
v16.0.0 | Turbopack is the default bundler; JS bundle size metrics removed from output |
v15.5.0 | Turbopack build support in beta |
v15.4.0 | --debug-prerender flag added |
