Deploying a Next.js app in production
By Flavio Copes
Learn how to build and run the production version of a Next.js app with next build and next start, getting optimized, prerendered static HTML pages.
Deploying an app made using Next.js in production is easy. Add those 3 lines to the package.json scripts section:
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
}
We used npm run dev up to now, to call next dev from the locally installed Next.js package. This started the development server, which provided us source maps and hot code reloading, two very useful features while debugging.
Then we build the website with npm run build, and we start the production app with npm run start.
Those 2 commands are the ones we must invoke to successfully deploy the production version of our site locally. The production version is highly optimized and does not come with source maps and other things like hot code reloading that would not be beneficial to our end users.
This still holds on current Next.js 16. New apps often use the App Router, but next build and next start stay the production pair.
So, let’s create a production deploy of our app. Build it using:
npm run build

The output of the command tells us that some routes (/ and /blog are now prerendered as static HTML, while /blog/[id] will be served by the Node.js backend.
Then you can run npm run start to start the production server locally:
npm run start

Visiting http://localhost:3000 will show us the production version of the app, locally.
Before you ship to a real server, I built a free deploy checklist tailored to your stack and platform, so you don’t forget the boring but important stuff.
Want me to talk about your product? You can sponsor this site.
Related posts about next: