Production Build
The following command compiles the application into an output folder:
npm run build
This command generates the application files in the .next
directory.
Build Output
The production build produces optimized assets within the .next
folder:
- HTML files for statically generated pages
- JavaScript bundles for client-side runtime
- Server-side code for handling API routes and server-side rendering
Running the Production Build
To launch the application in production mode, execute:
npm run start
This command initiates the Next.js production server.
Environment Variables
Make sure all required environment variables are configured for the production environment. Use the .env.production
file to define production-specific variables.
Analyzing the Bundle
To examine the production bundle size, run:
ANALYZE=true npm run build
This generates a report to assist in optimizing your application’s bundle size.