TL;DR: In Next.js, next dev
is used to run the app in development mode. On the other hand, next start
is used to run the app in production mode, but requires next build
to be run first to generate an optimized production build.
Development
When running the Next.js app in development, you’ll want to use next dev
:
next dev
starts the application in development mode with hot-code
reloading, error reporting, and more.
Production
When building the Next.js app for production, you’ll want to use next build
:
next build
creates an optimized production build of your
application. The output displays information about each route.
- Size – The number of assets downloaded when navigating to the page
client-side. The size for each route only includes its dependencies.- First Load JS – The number of assets downloaded when visiting the page
from the server. The amount of JS shared by all is shown as a separate
metric.
Followed by either next start
, when you want to start the production server:
next start
starts the application in production mode. The
application should be compiled withnext build
first.
Or next export
, when exporting the app as static HTML:
next export
allows you to export your app to static HTML, which can be
run standalone without the need of a Node.js server.
For more information refer to Next.js CLI docs.