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.
| Command | What it does |
|---|---|
| dev | Starts the development server |
| build | Creates an optimized production build |
| start | Serves the production build |
| info | Prints system details for bug reports |
| telemetry | Enables or disables anonymous telemetry |
| typegen | Generates route types without a full build |
| upgrade | Upgrades 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.
npm run buildThe 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
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.
Frequently Asked Questions
What does running next with no command do?
How do I see the installed Next.js version?
What is next typegen for?
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.
More in this topic
`generateMetadata` Explained with Real Examples
What generateMetadata does, when it runs, and how to use it for real routes: awaited params, deduplicated data fetching, extending parent metadata, and returning a 404 from metadata.
Canonical URLs in Next.js: `metadataBase`, `alternates.canonical`, and Dynamic Pages
How canonical URLs work in the Next.js App Router: setting metadataBase once, writing alternates.canonical per route, handling dynamic segments, and what happens when the base URL is missing.
Open Graph and Twitter Card Metadata in Next.js
How to write Open Graph and Twitter card metadata in the Next.js App Router: the openGraph and twitter fields, automatic card defaults, article tags, and image merge rules.