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:
- Client (Frontend): Next.js application → Deploy to Vercel (recommended)
- Server (Backend): Express application → Deploy to Heroku, Railway, or similar
Deploy the Client (Frontend)
Option 1: Vercel (Recommended)
Vercel is built by the creators of Next.js and offers the best experience for Next.js applications.
Connect Your Repository
- Go to Vercel
- Sign up/login with GitHub
- Click “Add New Project”
- Import your
fast-forward-dev-clientrepository
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)
- Go to your project settings
- Click “Domains”
- Add your custom domain
- Follow DNS configuration instructions
Option 2: Netlify
Install Netlify CLI
npm install -g netlify-cliBuild Your Application
cd my-project-client
npm run buildDeploy
netlify deploy --prodSet Environment Variables
In Netlify dashboard:
- Go to “Site settings” → “Environment variables”
- 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-nameAdd Buildpack
heroku buildpacks:set heroku/nodejsConfigure 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 masterVerify Deployment
heroku logs --tail
heroku openOption 2: Railway
Sign Up for Railway
Go to Railway.app and sign up
Create New Project
- Click “New Project”
- Select “Deploy from GitHub repo”
- Choose your
fast-forward-dev-serverrepository
Configure Environment Variables
In Railway dashboard, add all environment variables:
MONGODB_URIJWT_SECRETSTRIPE_SECRET_KEYSTRIPE_WEBHOOK_SECRETRESEND_API_KEYGOOGLE_CLIENT_IDNODE_ENV=productionCLIENT_URL
Deploy
Railway will automatically deploy your application.
Option 3: DigitalOcean App Platform
Create an App
- Go to DigitalOcean
- Create new App
- 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:
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
- Go to Stripe Dashboard
- Switch to Live mode (toggle in dashboard)
- Go to “Developers” → “Webhooks”
- Click “Add endpoint”
Set Endpoint URL
Use your production server URL:
https://your-server-domain.com/api/stripe/webhookSelect Events
Add these events:
checkout.session.completedcustomer.subscription.updatedcustomer.subscription.deletedinvoice.paidinvoice.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
- Go to Google Cloud Console
- Navigate to your OAuth client
- Add production redirect URIs:
https://yourdomain.com/api/auth/callback/google
Update Authorized Origins
Add:
https://yourdomain.comDatabase Setup (MongoDB)
MongoDB Atlas Production Cluster
Create Production Cluster
- Go to MongoDB Atlas
- Create a new cluster or use existing
- Choose appropriate tier (M2+ for production)
Configure Network Access
- Go to “Network Access”
- Add IP addresses of your hosting provider
- Or use
0.0.0.0/0(less secure, but works with all hosts)
Create Database User
- Go to “Database Access”
- Create a new user with strong password
- Grant read/write access
Get Connection String
- Click “Connect” on your cluster
- Choose “Connect your application”
- Copy the connection string
- 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/nodeConfigure 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)
- Go to your project
- Click “Deployments”
- Find the last working deployment
- Click the three dots → “Promote to Production”
Heroku (Server)
# View releases
heroku releases
# Rollback to previous release
heroku rollback v123Railway (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_URLin server matches your frontend domain - Check
backendUrlin client config points to server
Authentication not working
- Verify
NEXTAUTH_URLmatches your domain exactly - Check Google OAuth redirect URIs include production URLs
- Ensure
NEXTAUTH_SECRETis 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