khmer
moon
0:00 / 2:00
Basic script in Next js

Basic script in Next js

Web Development

Published on

August 29, 2022

Script: next dev vs next build vs next start

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 with `next build` first.

{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  },
}

More Articles

How We Use AI in Fintech

How We Use AI in Fintech

Artificial intelligence has helped organizations boost their bottom line by streamlining programs and procedures.

26th September 2022

Zustand - React state management

Zustand - React state management

Zustand is a state management library for React that is lightweight and straightforward to use.

26th August 2022