Deploy

    Once you have your project running locally, you can deploy it to production. Your Next.js application can be deployed to any platform that supports Node.js.

    Building for Production

    Most deployment platforms (like Vercel and Netlify) automatically build your application during deployment. However, you can test your production build locally before deploying:

    # Build the application locally (optional)
    pnpm build
    # or
    npm run build
    # or
    yarn build
    
    # Test the production build locally
    pnpm start
    # or
    npm start
    # or
    yarn start

    Deployment Platforms

    Vercel is built by the creators of Next.js and offers the best integration experience:

    Vercel deployment

    Deploy your app to Vercel

    1. Connect your repository:

      • Visit Vercel Dashboard
      • Click "Add New" → "Project"
      • Import your GitHub repository
    2. Add environment variables:

      • Go to Project Settings → Environment Variables
      • Add your production environment variables
      • Copy from your .env.local file
    3. Deploy:

      • Click "Deploy"
      • Your app will be live in minutes

    Netlify

    Netlify offers great static site hosting with serverless functions:

    Netlify deployment

    Deploy your app to Netlify

    1. Connect your repository:

      • Visit Netlify Dashboard
      • Click "Add new site" → "Import an existing project"
      • Connect your Git provider and select your repository
    2. Configure build settings:

      • Build command: pnpm build (or npm run build or yarn build)
      • Publish directory: .next
    3. Add environment variables:

      • Go to Site Settings → Environment Variables
      • Add your production environment variables
      • Copy from your .env.local file
    4. Deploy:

      • Click "Deploy site"
      • Your site will be live shortly

    Other Platforms

    • Railway - Zero-configuration deployments with automatic HTTPS and database integration
    • DigitalOcean App Platform - Auto-detects Next.js projects with simple configuration
    • AWS Amplify - Amazon's hosting platform with CI/CD and serverless backend
    • Firebase Hosting - Google's platform with integrated backend services
    • Cloudflare Pages - Fast global edge network with automatic deployments