The Next.js CLI: Every Command and Flag Explained

The Next.js CLI is one command with subcommands for dev, build, start, and utilities. Learn each command and its key flags.

6 min read

The Next.js CLI is a single command, next, with a subcommand for every stage of the app lifecycle. Running next with no subcommand starts the development server, and each subcommand takes its own flags. You will use three of them every day, and the rest are there for debugging, upgrades, and CI.

CommandWhat it does
devStarts the development server
buildCreates an optimized production build
startServes the production build
infoPrints system details for bug reports
telemetryEnables or disables anonymous telemetry
typegenGenerates route types without a full build
upgradeUpgrades Next.js to the latest version

Most projects only touch the first three. The rest are utilities you reach for when debugging, upgrading, or wiring type checks into CI, and they are all safe to run whenever you need them.

Shared flags

Every command accepts -h for help, and the CLI as a whole accepts -v for the version. Most flags are specific to one command, but these two work everywhere, and they are the quickest way to see what is available without leaving the terminal.

The dev command

next dev starts the development server with hot reloading, and it is the command you run most often while building. Its flags cover ports, hostnames, and the bundler, with Turbopack as the default and --webpack as the opt-out. For the full list, read Running the Next.js Dev Server.

The build command

next build compiles the app for production, and running it before deploying catches type errors and prerender problems before users see them. Useful flags include --webpack to switch bundlers, --debug for verbose output, and --debug-prerender to get readable stack traces for prerender failures.

bashbash
npm run build

The route table this command prints is explained in Understanding next build Output.

The start command

next start serves the production build and must run after next build. It accepts the same port and hostname flags as the dev server, plus --keepAliveTimeout for servers that sit behind a load balancer. The server it starts is much faster than the dev server and closer to what users actually hit.

The utility commands

next info prints the operating system, Node version, and package versions, which is what you paste into a bug report. next typegen writes route types so tsc --noEmit can check them in CI without a full build. next upgrade moves the project to the latest release, and next telemetry turns anonymous usage reporting on or off.

Rune AI

Rune AI

Key Insights

  • The next CLI has subcommands for every stage of the app lifecycle.
  • next dev, next build, and next start cover the daily workflow.
  • next info and next typegen help with debugging and type checking.
  • Turbopack is the default bundler, with --webpack as the opt-out.
  • Every command accepts -h for help.
RunePowered by Rune AI

Frequently Asked Questions

What does running next with no command do?

It is an alias for next dev, so it starts the development server. Use a subcommand when you want a different stage, such as build or start.

How do I see the installed Next.js version?

Run next --version, or next -v. This prints the version without starting a server or build.

What is next typegen for?

It generates TypeScript route types without a full build, which is useful for running tsc --noEmit in a CI pipeline.

Conclusion

The Next.js CLI is a small set of commands around a single next binary. Most projects use dev, build, and start, while info, typegen, telemetry, and upgrade cover debugging and maintenance.