Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Next.js 16+ · Command

next build

next build compiles a Next.js application for production, prerenders eligible routes, and writes the result to .next/. It also reports how routes are served.

How it works

Run the command from the project directory after configuring the application. Next.js loads environment variables and configuration, discovers routes, compiles application code, analyzes rendering, prerenders eligible routes, and writes the result to .next/; it also prints a route table. Use the generated build with next start for production Node.js hosting.

Syntax

next build [options]

Parameters

NameTypeDescription
--debug-prerenderflagEnables more detailed output for prerendering errors.
--webpackflagUses webpack instead of Turbopack for the build.

Returns

Creates an optimized production build in .next/ and displays route information.

Key points

  • Creates the optimized production application that can be started by the production server.
  • The build pre-renders routes when possible and reports each route's serving strategy.
  • The setup phase incorporates environment files, checks configuration, and assigns the build identifier.
  • Compilation handles the different runtime targets and uses Turbopack by default, with webpack as an alternative.
  • The generated production artifacts are placed in the .next directory.
  • Run this command before launching the application with next start in production mode.

Common mistakes

  • Standalone output changes what is emitted, so deploy the generated standalone runtime rather than assuming every project file is included.

Example: Build for production

npm run build

Runs the package script that invokes Next.js to create the production build.

When to use it

Production builds

Create artifacts for a production deployment.

Route analysis

Inspect which routes are static, prerendered, or dynamically rendered.

Self-hosting

Produce a minimal Node.js deployment with standalone output.

Debugging prerender errors

Investigate failures during prerendering.

  • next start
  • next dev
  • Turbopack
  • output: 'standalone'
  • generateBuildId

Source: Building | Next.js. Checked 2026-10-15.