Getting Started
Development
Configuration
Deployment
Other
Build production
This section covers the steps to deploy your app to a live environment. Whether you're using Vercel or a custom hosting solution, follow these guidelines to ensure a smooth deployment process.
For detailed instructions on platform-specific deployments, refer to the Next.js Deployment Documentation.
Preparing for Deployment
Before deploying, ensure that your app is production-ready:
- Environment Variables:
Verify that all required variables (e.g., API keys, database URLs) are correctly set in your environment configuration. - Build Optimizations
Run the following command to create an optimized production build:
npm run build - Testing
Test your app locally using the production build to identify potential issues:
npm run start
Deploying to Vercel
Vercel is a popular platform for deploying Next.js apps.
- Connect to Vercel: Sign in toVercel and import your Git repository.
- Configure Build Settings: Ensure the framework is set toNext.js, and the build command is
npm run build. - Environment Variables: Add environment variables directly in the Vercel dashboard.
- Deploy: ClickDeploy, and Vercel will automatically handle the rest.
Custom Hosting
If you're deploying to a custom server or VPS, make sure Node.js installed on your server.
- Build the App: Run the production build
npm run build - Build the App
npm run startYou can use a process manager like
pm2orDockerto manage your app