Development & Deployment
Deploy to Production
Comprehensive guide for deploying your application to production using Vercel and Convex
Deploying to Production Guide
This guide provides instructions for deploying the application to production using Vercel and Convex.
Date: June 2025
Prerequisites
- A Git repository with your code (GitHub, GitLab, or Bitbucket)
- A Vercel account
- Production accounts for:
Step 1: Prepare Your Repository
- Ensure all your changes are committed
- Push your code to your Git repository
- Make sure your
.env
and.env.local
files are in.gitignore
Step 2: Deploy Backend to Convex
- Deploy your backend to Convex:
- Note your production deployment URL:
https://your-project-name.convex.cloud
Step 3: Configure Production Services
Clerk Setup
- Create a new production application in Clerk (or switch to production mode)
- Get your production API keys
- Set up the JWT template for Convex:
- Go to JWT Templates
- Create a new Convex template
- Save the issuer URL
Polar Setup
- Switch to polar.sh (not sandbox)
- Create your production organization
- Set up your production plans
- Get your production API keys and organization ID
Resend Setup
- Verify your production domain
- Create a production API key
- Generate a webhook signing secret
Step 4: Set Convex Environment Variables
In the Convex Dashboard, add these environment variables:
Step 5: Deploy to Vercel
-
Go to Vercel
-
Create a new project
-
Import your Git repository
-
Configure the build settings:
- Framework Preset: Vite
- Build Command:
npm run build
- Output Directory:
dist
- Install Command:
npm install --legacy-peer-deps
-
Add these environment variables in Vercel:
Note: All other environment variables (FRONTEND_URL, email configuration, etc.) should be set in your Convex deployment, not in Vercel.
- Deploy the project
Step 6: Configure Webhooks
Polar Webhooks
- In Polar dashboard:
- Go to Webhooks
- Add endpoint:
https://your-convex-deployment.convex.cloud/payments/webhook
- Format: Raw
- Select all event types
- Save the webhook
Resend Webhooks
- In Resend dashboard:
- Go to Webhooks
- Add endpoint:
https://your-convex-deployment.convex.cloud/resend-webhook
- Save the webhook
Step 7: Update Service Configurations
Clerk
- In Clerk Dashboard:
- Add your Vercel domain to allowed origins
- Update OAuth callback URLs
- Update any email templates with production URLs
Polar
- Update subscription success/cancel URLs to your production domain
- Test a subscription with a real card
Resend
- Set up domain authentication for better deliverability
- Create production email templates
Step 8: Final Testing
-
Test the complete user flow:
- Sign up
- Email verification
- Subscription process
- Dashboard access
- Settings page
- Subscription management
-
Monitor logs in:
- Convex Dashboard
- Clerk Dashboard
- Polar Dashboard
- Resend Dashboard
Production Checklist
- All environment variables are set in Convex
- All environment variables are set in Vercel
- Clerk JWT template is configured
- Polar webhooks are pointing to production URL
- Resend webhooks are pointing to production URL
- Domain verification is complete in Resend
- All OAuth callbacks are updated in Clerk
- Subscription plans are set up in Polar
- OpenAI API key has sufficient quota
- Error monitoring is set up in Convex
Troubleshooting
- If webhooks aren’t working, verify the endpoint URLs and secrets
- If emails aren’t sending, check Resend domain verification
- If auth isn’t working, verify Clerk origins and JWT configuration
- If subscriptions fail, check Polar webhook configuration
- Monitor Convex logs for any backend errors