Deploying to Production
This guide provides step-by-step instructions for deploying your Kaizen application to production using Vercel and transitioning all services from development to production environments.
You’ll need a custom domain for production deployment. Services like Clerk and Polar require verified domains for production environments. Purchase a domain from providers like Namecheap, Porkbun, or GoDaddy before proceeding.
Prerequisites
- ✅ A custom domain (purchased and ready)
- ✅ Your code committed and pushed to GitHub/GitLab/Bitbucket
- ✅ All development features working locally
- ✅ Production accounts for your enabled services
Clerk Authentication
For Email/Password Only (Simplest):
- In your existing Clerk application, go to Configure → Instance Settings
- Switch from “Development” to “Production” mode
- Update your domain settings:
- Add your production domain (e.g.,
https://yourdomain.com
)
- Remove localhost URLs
- Copy your new production API keys:
VITE_CLERK_PUBLISHABLE_KEY
(starts with pk_live_
)
CLERK_SECRET_KEY
(starts with sk_live_
)
For OAuth Providers (Google, etc.):
- Follow the Clerk OAuth setup guide for each provider
- Update OAuth callback URLs to your production domain
- For Google OAuth specifically:
- Update “Authorized JavaScript origins” to your production domain
- Update “Authorized redirect URIs” to use your production Clerk instance
- Ensure your Google OAuth app is set to “In production” status (not “Testing”)
Polar.sh Payments
-
Switch to production Polar:
- Log out of
sandbox.polar.sh
- Log into
polar.sh
(production)
- Create your production organization
- Set up your subscription plans with real pricing
-
Get production API keys:
- Go to Settings → API Keys
- Copy your
POLAR_ACCESS_TOKEN
(starts with polar_
)
- Copy your
POLAR_ORGANIZATION_ID
(starts with org_
)
Resend Email Service
-
Create production API key:
- In Resend dashboard, go to API Keys
- Create new key with “Full Access”
- Copy the API key (starts with
re_
)
-
Set up custom domain (Recommended):
- Go to Domains → Add Domain
- Enter your domain (e.g.,
yourdomain.com
)
- Add the required DNS records to your domain registrar
- Wait for verification (can take up to 24 hours)
- Use
noreply@yourdomain.com
as your sender email
OpenAI (If Enabled)
- Use existing API key or create a new production key
- Ensure sufficient credits for production usage
Step 2: Set Up Convex Production Environment
Add Environment Variables to Convex Production
- Go to your Convex Dashboard → Switch to Production environment
- Navigate to Settings → Environment Variables
- Add the following variables:
# Frontend Configuration
FRONTEND_URL=https://yourdomain.com
# Company Configuration
COMPANY_NAME=Your Company Name
SENDER_EMAIL=noreply@yourdomain.com
# Clerk JWT Integration
VITE_CLERK_FRONTEND_API_URL=https://your-app.clerk.accounts.dev
# Polar.sh (Production)
POLAR_ACCESS_TOKEN=polar_...
POLAR_ORGANIZATION_ID=org_...
POLAR_WEBHOOK_SECRET=whsec_...
# Resend (Production)
RESEND_API_KEY=re_...
RESEND_WEBHOOK_SECRET=whsec_...
# OpenAI (If enabled)
OPENAI_API_KEY=sk-...
Webhook secrets will be generated in Step 5 when you configure webhooks. Add placeholders for now.
Step 3: Deploy Backend to Convex Production
Now that your production environment variables are configured, deploy your Convex backend:
-
Deploy your Convex backend to production:
-
Note your production deployment URL (e.g., https://posh-cassowary-60.convex.cloud
)
-
Configure Convex for Vercel deployment (one-time setup):
npx convex deploy --cmd-url-env-var-name VITE_CONVEX_URL --cmd 'npm run build'
Convex will now deploy successfully since all required environment variables are configured.
Step 4: Deploy Frontend to Vercel
-
Connect your repository to Vercel:
- Go to vercel.com and create new project
- Import your Git repository
- Select your framework preset as Vite
-
Configure build settings:
- Build Command:
npm run build
- Output Directory:
dist
- Install Command:
npm install --legacy-peer-deps
-
Add environment variables in Vercel:
Required for all deployments:
VITE_CONVEX_URL=https://your-project.convex.cloud
VITE_CLERK_PUBLISHABLE_KEY=pk_live_...
CLERK_SECRET_KEY=sk_live_...
-
Deploy the project - Vercel will automatically deploy
-
Set up custom domain:
- In Vercel dashboard, go to Settings → Domains
- Add your custom domain
- Follow DNS setup instructions
Polar.sh Webhooks
-
In Polar dashboard:
- Go to Settings → Webhooks
- Click Add Endpoint
- URL:
https://your-project.convex.cloud/payments/webhook
- Format: Raw
- Events: Select all events
- Click Generate new secret and copy it
-
Update Convex environment variable:
- Add
POLAR_WEBHOOK_SECRET=whsec_...
to your Convex production environment
Resend Webhooks
-
In Resend dashboard:
- Go to Webhooks → Add Endpoint
- URL:
https://your-project.convex.cloud/resend-webhook
- Events: Select all
email.*
events
- Copy the webhook signing secret
-
Update Convex environment variable:
- Add
RESEND_WEBHOOK_SECRET=whsec_...
to your Convex production environment
Step 6: Final Configuration Updates
Update Clerk Production Settings
-
Add production domains:
- Go to Configure → Instance Settings
- Add your production domain to allowed origins
- Remove development/localhost URLs
-
Update JWT Template for Convex:
- Go to Configure → JWT Templates
- Find your Convex template
- Ensure it’s properly configured for production
Update Frontend URL in Convex
Critical: Update the FRONTEND_URL
in your Convex production environment variables to your actual domain:
FRONTEND_URL=https://yourdomain.com
Step 7: Test Production Deployment
Complete User Flow Test
-
Authentication:
- Sign up with a new account
- Verify email works
- Test login/logout
-
Payments (if enabled):
- Test subscription signup
- Use test card:
4242 4242 4242 4242
- Verify dashboard access after payment
- Test subscription management
-
Core Features:
- Test all main app functionality
- Verify real-time features work
- Test email notifications
Monitor Service Dashboards
Check logs and metrics in:
- Convex Dashboard → Logs
- Clerk Dashboard → Activity
- Polar Dashboard → Webhooks
- Resend Dashboard → Logs
- Vercel Dashboard → Functions
Production Checklist
Troubleshooting
Authentication Issues:
- Verify Clerk domain settings include your production URL
- Check JWT template configuration in Clerk
- Ensure OAuth apps are in “production” mode (not “testing”)
Payment Issues:
- Verify Polar webhook URL points to production Convex
- Check webhook secret matches in both Polar and Convex
- Ensure using production Polar account (not sandbox)
Email Issues:
- Verify domain authentication in Resend
- Check webhook secret matches in both Resend and Convex
- Ensure sender email domain is verified
General Issues:
- Check Convex logs for backend errors
- Verify all environment variables are set correctly
- Ensure frontend URL is set correctly in Convex (no trailing slash)
🎉 Congratulations! Your Kaizen application is now live in production. Monitor your service dashboards for the first few days to ensure everything is working smoothly.
Responses are generated using AI and may contain mistakes.