Next.jsEasy
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
cacheLifetiming and ISR are not observable. - Dev-only checks: Cache Components validation insights, hydration diffs, Instant Navigation validation, Server Function logs.
- Outputs to
.next/devsince 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 lintin 16). - Prerenders static shells and
generateStaticParamspaths; fails on build errors such as blocking routes orensureStaticviolations. - Minifies and mangles code, extracts CSS, optimizes chunks.
- Writes
.next(orstandalone/outdepending onoutput). - Next.js 16 removed per-route
sizeandFirst Load JScolumns 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.json2// {3// "scripts": {4// "dev": "next dev", // http://localhost:3000, HMR, overlays5// "build": "next build", // production build into .next6// "start": "next start", // serve the production build7// "lint": "eslint .", // next lint was removed in Next.js 168// "typecheck": "tsc --noEmit"9// }10// }1112// Typical local production check:13// npm run build && npm run start14// Debug a failing prerender with readable stack traces:15// next build --debug-prerender16// 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.