Production Build
The following command builds the application into an output directory:
npm run build
This command compiles the application into the .next
directory.
Build Output
The production build creates optimized assets in 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 start the application in production mode, run:
npm run start
This command starts the Next.js production server.
Environment Variables
Ensure that all necessary environment variables are set for the production environment. You can use .env.production
file for production-specific variables.
Analyzing the Bundle
To analyze the production bundle size, you can use:
ANALYZE=true npm run build
This will generate a report to help you optimize your application's bundle size.