Skip to main content
doc0blade47/next.jsdocumentation home
Sign in

Deploying to Production

Last updated Oct 12, 2026100% grounded

Overview

Introduction

Deploying your Next.js application to production involves creating an optimized production build and starting your application server on a cloud hosting platform or a custom server. Next.js prepares your application by compiling code, optimizing assets, and generating static pages so your visitors experience fast load times and reliable performance.


Creating a Production Build

Before deploying your application to any hosting environment, you need to generate an optimized production bundle.

  1. Open your terminal in your project's root directory.
  2. Run the production build command:
    next build
  3. Wait for the build process to finish. The output displays information about each route, bundle sizes, and any build warnings or errors.

Tip

If you want to use Turbopack for your production build, you can include the --turbo or --turbopack flag when running the build command.


Starting the Production Server

Once your project is successfully built, you can start the production server to handle live traffic.

  1. Open your terminal in your project's root directory.
  2. Run the start command:
    next start
  3. The server will launch on the default port (3000) or the port specified by your hosting environment.

Configuration and Build Options

When building or running your application for production, you can customize the process using various command-line flags.

Flag / OptionDescription
--turbo, --turbopackBuilds or starts your application using Turbopack.
--webpackForces the build to use the bundled webpack.
--port <port>Specifies a custom port number for the production server.
-d, --debugEnables verbose build output for troubleshooting.
--profileEnables production profiling for React.
--no-manglingDisables code mangling (recommended for debugging purposes only).

Troubleshooting Common Build Issues

If your build encounters problems, review the following guidelines:

Warning

Running code optimization with --no-mangling or enabling debug modes like debug-prerender will affect performance and should never be used for live production environments.

Important

If you see an error stating that native bindings are not available for Turbopack on your specific platform architecture, fall back to Webpack by running next build --webpack.

Was this page helpful?