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.

  1. Connect to Vercel: Sign in toVercel and import your Git repository.
  2. Configure Build Settings: Ensure the framework is set toNext.js, and the build command isnpm run build.
  3. Environment Variables: Add environment variables directly in the Vercel dashboard.
  4. 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.

  1. Build the App: Run the production build
    npm run build
  2. Build the App
    npm run start

    You can use a process manager like pm2 or Docker to manage your app