Back to Help Center
Getting Started

Deployment Guide

Deployment Guide

This guide covers deploying your SaaS to production.

Vercel Deployment (Recommended)

One-Click Deploy

Deploy with Vercel

Manual Deployment

  1. Push your code to GitHub
  2. Go to vercel.com and sign in
  3. Click Add New > Project
  4. Import your repository
  5. Configure environment variables (see below)
  6. Click Deploy

Environment Variables

Add these in Vercel project settings > Environment Variables:

# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

# Stripe (use live keys for production!)
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_...
STRIPE_SECRET_KEY=sk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...
NEXT_PUBLIC_STRIPE_PRICE_ID_FREE=price_...
NEXT_PUBLIC_STRIPE_PRICE_ID_PRO_MONTHLY=price_...
NEXT_PUBLIC_STRIPE_PRICE_ID_PRO_YEARLY=price_...
NEXT_PUBLIC_STRIPE_PRICE_ID_ENTERPRISE_MONTHLY=price_...
NEXT_PUBLIC_STRIPE_PRICE_ID_ENTERPRISE_YEARLY=price_...

# Resend
RESEND_API_KEY=re_...
EMAIL_FROM=YourApp <noreply@yourdomain.com>
EMAIL_REPLY_TO=support@yourdomain.com

# App URL (your production domain)
NEXT_PUBLIC_APP_URL=https://yourdomain.com

Custom Domain Setup

In Vercel

  1. Go to your project > Settings > Domains
  2. Add your domain (e.g., yourdomain.com)
  3. Follow instructions to update DNS records
  4. Wait for SSL certificate provisioning

DNS Configuration

Add these records at your DNS provider:

| Type | Name | Value | |------|------|-------| | A | @ | 76.76.21.21 | | CNAME | www | cname.vercel-dns.com |

Production Checklist

Supabase

  • [ ] Update Site URL in Auth settings to your production domain
  • [ ] Add production domain to Redirect URLs
  • [ ] Review and tighten RLS policies
  • [ ] Enable database backups
  • [ ] Consider upgrading to a paid plan for production workloads

Stripe

  • [ ] Create products and prices in live mode
  • [ ] Update to live API keys
  • [ ] Set up production webhook endpoint:
    • URL: https://yourdomain.com/api/stripe/webhooks
    • Events: checkout.session.completed, customer.subscription.*, invoice.*
  • [ ] Configure customer portal return URL
  • [ ] Test with a real card (small amount, then refund)

Resend

  • [ ] Verify your production domain
  • [ ] Update EMAIL_FROM to use your domain
  • [ ] Test email delivery
  • [ ] Consider upgrading plan for higher volume

Google OAuth (if using)

  1. Go to Google Cloud Console
  2. Update OAuth credentials:
    • Add production redirect URI: https://your-project.supabase.co/auth/v1/callback
    • Update authorized JavaScript origins
  3. Submit for verification if needed

Security

  • [ ] Ensure all secrets are in environment variables (not in code)
  • [ ] Enable 2FA on all service accounts
  • [ ] Review CORS settings in Supabase
  • [ ] Set up error monitoring (e.g., Sentry)
  • [ ] Configure rate limiting if needed

Post-Deployment

Verify Everything Works

  1. Sign up with email and password
  2. Sign up with Google OAuth
  3. Subscribe to a paid plan
  4. Manage subscription through customer portal
  5. Receive emails (welcome, subscription confirmation)
  6. Check webhooks are processing correctly

Monitor

  • Set up Vercel Analytics
  • Monitor Stripe webhook events
  • Check Resend delivery stats
  • Set up error alerting

Scaling Considerations

Database

  • Use Supabase connection pooling
  • Add indexes for frequently queried columns
  • Consider read replicas for heavy read loads

Caching

  • Use Vercel Edge Config for feature flags
  • Implement Redis for session/data caching
  • Use ISR for blog pages

CDN

Vercel automatically serves your app from the edge, but consider:

  • Image optimization with next/image
  • Static asset caching headers
  • API route caching where appropriate

Rollback

If something goes wrong:

  1. Vercel: Click on a previous deployment > Promote to Production
  2. Database: Restore from Supabase backups
  3. Stripe: Use test mode to debug, then re-deploy

Environment-Specific Builds

For different configurations per environment:

// next.config.js
module.exports = {
  env: {
    ENVIRONMENT: process.env.VERCEL_ENV || 'development',
  },
};
// In your code
if (process.env.ENVIRONMENT === 'production') {
  // Production-only code
}

Troubleshooting

Build Fails

  • Check build logs in Vercel
  • Ensure all env vars are set
  • Run npm run build locally to debug

Webhooks Not Working

  • Verify webhook URL is correct
  • Check webhook signing secret
  • View webhook logs in Stripe Dashboard

OAuth Redirect Errors

  • Verify redirect URLs in Supabase and Google
  • Check Site URL in Supabase matches your domain
  • Ensure SSL is working (no mixed content)

Database Connection Issues

  • Check Supabase project is running
  • Verify connection string
  • Check RLS policies aren't blocking access