Deployment

Deploy LaunchSaaS to production on Vercel, Railway, or Docker

Deployment

This guide covers deploying LaunchSaaS to production, including platform-specific instructions and best practices.

Pre-Deployment Checklist

Before deploying, ensure you have:

  • Database set up and accessible from production
  • All required environment variables configured
  • Database migrations applied (npm run db:migrate)
  • Admin user created (npm run init:scripts)
  • Stripe webhooks configured with production URL
  • Email domain verified in Resend
  • Social OAuth apps configured with production callback URLs
  • APP_ENV set to production
  • NEXT_PUBLIC_APP_URL set to your production domain

Vercel is the creators of Next.js and offers the best deployment experience.

Deploy via Dashboard

  1. Go to vercel.com
  2. Click "Add New Project"
  3. Import your Git repository
  4. Configure environment variables (add all from your .env file)
  5. Click "Deploy"

Deploy via CLI

  1. Install Vercel CLI:
npm install -g vercel
  1. Login and deploy:
vercel login
vercel --prod

Environment Variables

Add all required environment variables in Vercel Dashboard:

  1. Go to Project Settings → Environment Variables
  2. Add each variable for "Production" environment
  3. Redeploy after adding variables

Custom Domain

  1. Go to Project Settings → Domains
  2. Add your domain
  3. Configure DNS (CNAME to cname.vercel-dns.com or use Vercel nameservers)
  4. Wait for DNS propagation

Railway

Railway offers simple deployment with database included.

Deploy to Railway

  1. Go to railway.app
  2. Click "New Project"
  3. Select "Deploy from GitHub repo"
  4. Select your repository
  5. Add environment variables
  6. Click "Deploy"

Database on Railway

Railway can provision a PostgreSQL database:

  1. Click "New" → "Database" → "PostgreSQL"
  2. Copy the connection string
  3. Add as DATABASE_URL environment variable

Docker

Deploy anywhere using Docker.

Build Docker Image

Create a Dockerfile in your project root:

FROM node:20-alpine AS base

FROM base AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci

FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build

FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

EXPOSE 3000
ENV PORT=3000
CMD ["node", "server.js"]

Build and Run

docker build -t launchsaas .
docker run -p 3000:3000 --env-file .env launchsaas

Post-Deployment

Update Webhook URLs

After deployment, update your Stripe webhook URL:

  1. Go to Stripe Dashboard → Webhooks
  2. Update endpoint URL to: https://yourdomain.com/api/auth/stripe/webhook

Update OAuth Callback URLs

Update social login callback URLs:

  • GitHub: https://yourdomain.com/api/auth/callback/github
  • Google: https://yourdomain.com/api/auth/callback/google

Verify Deployment

  1. Visit your production URL
  2. Test sign up and sign in
  3. Test payment flow with Stripe test cards
  4. Verify emails are being sent
  5. Check admin panel access

Next Steps