What is the difference between next build and next dev?

next dev starts a development server that compiles routes on demand, with hot module replacement, error overlays, DevTools and unminified code. next build creates an optimized production build: it compiles everything, prerenders static content, minifies, and writes output that next start (or a platform) serves.

next dev

  • Turbopack by default (since Next.js 16), with a persistent disk cache, so restarts are fast.
  • Compiles routes lazily as you visit them.
  • Fast Refresh preserves component state on edits.
  • Renders every request on demand: no prefetching, pages are not cached, so cacheLife timing and ISR are not observable.
  • Dev-only checks: Cache Components validation insights, hydration diffs, Instant Navigation validation, Server Function logs.
  • Outputs to .next/dev since Next.js 16, so dev and build can run at the same time.
  • Flags: --port, --hostname, --experimental-https, --inspect, --webpack.

next build

  • Compiles all routes, type-checks TypeScript, and no longer runs ESLint (removed with next lint in 16).
  • Prerenders static shells and generateStaticParams paths; fails on build errors such as blocking routes or ensureStatic violations.
  • Minifies and mangles code, extracts CSS, optimizes chunks.
  • Writes .next (or standalone/out depending on output).
  • Next.js 16 removed per-route size and First Load JS columns from the output.
  • Flags: --debug, --profile, --analyze, --debug-prerender, --debug-build-paths, --webpack.

Then next start

Runs the production server. Always test performance, caching and prefetching with next build && next start, never with next dev.

Code example

tsx
1// package.json
2// {
3// "scripts": {
4// "dev": "next dev", // http://localhost:3000, HMR, overlays
5// "build": "next build", // production build into .next
6// "start": "next start", // serve the production build
7// "lint": "eslint .", // next lint was removed in Next.js 16
8// "typecheck": "tsc --noEmit"
9// }
10// }
11
12// Typical local production check:
13// npm run build && npm run start
14// Debug a failing prerender with readable stack traces:
15// next build --debug-prerender
16// Build only some routes while debugging:
17// next build --debug-build-paths="app/blog/**"

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the Next.js set.

Open in study app