Development Workflow & CLI
Every Next.js project revolves around the same small set of CLI commands, provided by the next package itself. create-next-app wires them into package.json scripts for you, so day-to-day you run them through npm run rather than typing next directly.
The core commands
Command | What it does |
|---|---|
| Starts the local development server with Fast Refresh, detailed error overlays, and no production optimizations. |
| Compiles an optimized production build — statically generating what it can, and preparing everything else to be rendered on demand. |
| Serves the output of |
| Runs ESLint using the |
The package.json convention
A scaffolded project wires each command up as an npm script, so you rarely type next directly:
package.json (scripts excerpt)
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
}
}npm run dev # develop locally npm run build # build for production npm run start # run the production build npm run lint # check for lint issues
Fast Refresh
While next dev is running, saving a file triggers Fast Refresh: edited components update in the browser almost instantly, and in most cases React component state is preserved across the edit — you do not lose your place in a form or a modal just because you tweaked some styling.
✓ Compiled /about in 87ms
Turbopack
Turbopack is a newer, Rust-based bundler built specifically for Next.js, designed to replace Webpack as the dev-server engine with significantly faster cold starts and incremental updates on large projects. You can opt into it explicitly:
next dev --turbo
next dev— local development with Fast Refresh.next build— creates the optimized production build.next start— serves that build as a Node.js server.next lint— lints the project with Next.js-aware rules.