The Next.js CLI

dev, build, start — That's the Whole CLI

The Next.js CLI

next dev runs Turbopack, next build optimizes for production, and next start serves the production build. A handful of commands cover the entire workflow.

4 min read Level 1/5 #nextjs#cli
What you'll learn
  • Run `next dev` with Turbopack
  • Run `next build` to produce a production bundle
  • Run `next start` to serve the build

The Next.js CLI is intentionally small. Three commands cover most days, and a couple of extras help with linting and diagnostics.

Dev Server

npm run dev
# under the hood: next dev --turbopack

next dev boots a development server backed by Turbopack. You get fast refresh, source maps, and detailed error overlays. Routes recompile on demand the first time you visit them.

Production Build

npm run build
# under the hood: next build

next build compiles your app for production. It:

  • Bundles client and server code separately
  • Prerenders static pages
  • Streams React Server Components
  • Reports each route as Static, Dynamic, or ISR in a final table

Start the Production Server

npm run start
# under the hood: next start

next start serves the output of next build on a Node.js server. Use it on a VM or container deploy. Platforms like Vercel skip this step and run the build artifacts directly.

The Rest

next lint   # run ESLint with the Next.js config
next info   # dump environment + version info for bug reports
next telemetry disable  # turn off anonymous usage data

That is the whole CLI surface. Next we look at where files belong in a Next.js project.

Project Structure →