Skip to Content
Getting StartedDeployment

Deployment

Deploy your Fast Forward Dev application to production with this comprehensive guide.

Before deploying to production, make sure you have:

  • Completed all environment variable setup
  • Tested your application locally
  • Set up production Stripe account
  • Configured a production MongoDB database
  • Obtained production API keys for all services

Deployment Overview

Fast Forward Dev consists of two separate applications that need to be deployed:

  1. Client (Frontend): Next.js application → Deploy to Vercel (recommended)
  2. Server (Backend): Express application → Deploy to Heroku, Railway, or similar

Deploy the Client (Frontend)

Vercel is built by the creators of Next.js and offers the best experience for Next.js applications.

Connect Your Repository

  1. Go to Vercel 
  2. Sign up/login with GitHub
  3. Click “Add New Project”
  4. Import your fast-forward-dev-client repository

Configure Environment Variables

Add all environment variables from your .env.local:

NEXTAUTH_URL=https://yourdomain.com NEXTAUTH_SECRET=your-production-secret PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_... GOOGLE_CLIENT_ID=... GOOGLE_CLIENT_SECRET=...

Don’t use PUBLIC_TEST_STRIPE_PUBLISHABLE_KEY in production. Use PUBLIC_STRIPE_PUBLISHABLE_KEY with your live key.

Deploy

Click “Deploy” and Vercel will automatically:

  • Build your Next.js application
  • Deploy to a global CDN
  • Set up a production URL
  • Enable automatic deployments for future Git pushes

Configure Custom Domain (Optional)

  1. Go to your project settings
  2. Click “Domains”
  3. Add your custom domain
  4. Follow DNS configuration instructions

Option 2: Netlify

Install Netlify CLI

npm install -g netlify-cli

Build Your Application

cd my-project-client npm run build

Deploy

netlify deploy --prod

Set Environment Variables

In Netlify dashboard:

  1. Go to “Site settings” → “Environment variables”
  2. Add all your environment variables

Deploy the Server (Backend)

Option 1: Heroku

Install Heroku CLI

Download from Heroku CLI 

Create a Heroku App

cd my-project-server heroku create my-app-name

Add Buildpack

heroku buildpacks:set heroku/nodejs

Configure Environment Variables

heroku config:set MONGODB_URI="your-mongodb-uri" heroku config:set JWT_SECRET="your-jwt-secret" heroku config:set STRIPE_SECRET_KEY="sk_live_..." heroku config:set STRIPE_WEBHOOK_SECRET="whsec_..." heroku config:set RESEND_API_KEY="re_..." heroku config:set GOOGLE_CLIENT_ID="..." heroku config:set NODE_ENV="production" heroku config:set CLIENT_URL="https://yourdomain.com"

Deploy

git push heroku master

Verify Deployment

heroku logs --tail heroku open

Option 2: Railway

Sign Up for Railway

Go to Railway.app  and sign up

Create New Project

  1. Click “New Project”
  2. Select “Deploy from GitHub repo”
  3. Choose your fast-forward-dev-server repository

Configure Environment Variables

In Railway dashboard, add all environment variables:

  • MONGODB_URI
  • JWT_SECRET
  • STRIPE_SECRET_KEY
  • STRIPE_WEBHOOK_SECRET
  • RESEND_API_KEY
  • GOOGLE_CLIENT_ID
  • NODE_ENV=production
  • CLIENT_URL

Deploy

Railway will automatically deploy your application.

Option 3: DigitalOcean App Platform

Create an App

  1. Go to DigitalOcean 
  2. Create new App
  3. Connect your GitHub repository

Configure Build Settings

  • Build Command: npm run build
  • Run Command: npm start

Add Environment Variables

Add all required environment variables in the app settings.

Deploy

Click “Deploy” to start the deployment process.

Update Backend URL in Client

After deploying your server, update the backend URL in your client configuration:

src/config/config.ts
export const appConfig = { nextConfig: { backendUrl: isProd() ? 'https://your-server-domain.herokuapp.com' // Your production server URL : 'http://localhost:5001', // ... }, // ... }

Redeploy your client after making this change.

Configure Stripe Webhooks for Production

Create Webhook Endpoint

  1. Go to Stripe Dashboard 
  2. Switch to Live mode (toggle in dashboard)
  3. Go to “Developers” → “Webhooks”
  4. Click “Add endpoint”

Set Endpoint URL

Use your production server URL:

https://your-server-domain.com/api/stripe/webhook

Select Events

Add these events:

  • checkout.session.completed
  • customer.subscription.updated
  • customer.subscription.deleted
  • invoice.paid
  • invoice.payment_failed

Get Webhook Secret

Copy the “Signing secret” and update your server environment variables:

STRIPE_WEBHOOK_SECRET=whsec_live_...

Configure Google OAuth for Production

Update Authorized Redirect URIs

  1. Go to Google Cloud Console 
  2. Navigate to your OAuth client
  3. Add production redirect URIs:
    https://yourdomain.com/api/auth/callback/google

Update Authorized Origins

Add:

https://yourdomain.com

Database Setup (MongoDB)

MongoDB Atlas Production Cluster

Create Production Cluster

  1. Go to MongoDB Atlas 
  2. Create a new cluster or use existing
  3. Choose appropriate tier (M2+ for production)

Configure Network Access

  1. Go to “Network Access”
  2. Add IP addresses of your hosting provider
  3. Or use 0.0.0.0/0 (less secure, but works with all hosts)

Create Database User

  1. Go to “Database Access”
  2. Create a new user with strong password
  3. Grant read/write access

Get Connection String

  1. Click “Connect” on your cluster
  2. Choose “Connect your application”
  3. Copy the connection string
  4. Update server environment variables

Environment Variables Checklist

Client (Frontend)

  • NEXTAUTH_URL - Your production domain
  • NEXTAUTH_SECRET - Production secret (different from dev)
  • PUBLIC_STRIPE_PUBLISHABLE_KEY - Live publishable key
  • GOOGLE_CLIENT_ID - OAuth client ID
  • GOOGLE_CLIENT_SECRET - OAuth client secret

Server (Backend)

  • MONGODB_URI - Production database connection
  • JWT_SECRET - Production JWT secret
  • STRIPE_SECRET_KEY - Live secret key (sk_live_)
  • STRIPE_WEBHOOK_SECRET - Production webhook secret
  • RESEND_API_KEY - Resend API key
  • GOOGLE_CLIENT_ID - OAuth client ID
  • NODE_ENV=production
  • CLIENT_URL - Your production frontend URL
  • PORT - Usually set by hosting provider

Post-Deployment

Test Your Application

Test Authentication

  • Email/password signup
  • Email/password login
  • Google OAuth login
  • Password reset (if implemented)

Test Stripe Integration

  • Checkout flow
  • Successful payment
  • Webhook processing
  • Subscription updates

Test Email Delivery

  • Welcome emails
  • Receipt emails
  • Verify emails arrive correctly

Monitor Logs

  • Check server logs for errors
  • Monitor client-side errors
  • Set up error tracking (Sentry, LogRocket, etc.)

Monitoring & Maintenance

Set Up Error Tracking

Sentry (Recommended):

npm install @sentry/nextjs npm install @sentry/node

Configure in both client and server for error tracking.

Set Up Analytics

Add analytics to track user behavior:

  • Google Analytics
  • Vercel Analytics
  • Plausible
  • PostHog

Monitor Performance

  • Monitor API response times
  • Check database performance
  • Track Core Web Vitals

Regular Maintenance

  • Keep dependencies updated
  • Monitor security vulnerabilities
  • Back up your database regularly
  • Review error logs weekly

Rollback Strategy

If something goes wrong:

Vercel (Client)

  1. Go to your project
  2. Click “Deployments”
  3. Find the last working deployment
  4. Click the three dots → “Promote to Production”

Heroku (Server)

# View releases heroku releases # Rollback to previous release heroku rollback v123

Railway (Server)

Railway automatically keeps deployment history. Use the dashboard to rollback to a previous deployment.

Security Checklist

  • All secrets are production-specific (not dev secrets)
  • MongoDB has IP restrictions or secure VPC
  • Stripe is in live mode with proper webhook signature verification
  • CORS is properly configured on server
  • HTTPS is enabled (automatic with Vercel)
  • Rate limiting is enabled on API endpoints
  • Environment variables are not exposed in client code

Troubleshooting

”Cannot connect to server” errors

  • Verify server is running: Visit your server URL directly
  • Check CORS configuration allows your client domain
  • Verify CLIENT_URL in server matches your frontend domain
  • Check backendUrl in client config points to server

Authentication not working

  • Verify NEXTAUTH_URL matches your domain exactly
  • Check Google OAuth redirect URIs include production URLs
  • Ensure NEXTAUTH_SECRET is set in production

Stripe webhooks failing

  • Verify webhook endpoint URL is correct
  • Check webhook secret is for production endpoint
  • Look at webhook logs in Stripe Dashboard
  • Ensure server is accessible from Stripe’s IPs

Next Steps

Your application is now deployed! Consider:

  • Admin Components - Manage your users
  • Setting up CI/CD for automatic deployments
  • Implementing monitoring and logging
  • Creating a backup strategy

Need help with deployment? Contact emillykkeg@gmail.com

Last updated on