Deploy the AI Starter Kit to production with Vercel (frontend) and Convex Cloud (backend).
- Code pushed to GitHub
- Convex production deployment created
- Production environment variables set
- Frontend deployed to Vercel
- Custom domain configured (optional)
- Tested in production
npx convex deployThis:
- Creates a production Convex deployment
- Pushes your schema and functions
- Returns a production URL (e.g.,
https://prod-abc123.convex.cloud)
# Generate a NEW secret for production
npx convex env set BETTER_AUTH_SECRET $(openssl rand -base64 32) --prod
# Set your production site URL (update after deploying frontend)
npx convex env set SITE_URL https://your-domain.vercel.app --prod# List production environment variables
npx convex env list --prod
# View production dashboard
npx convex dashboard --prod-
Push to GitHub
git add . git commit -m "Prepare for deployment" git push origin main
-
Import to Vercel
- Go to vercel.com
- Click "Add New Project"
- Import your GitHub repository
- Vercel auto-detects Next.js
-
Configure Environment Variables
- Add
NEXT_PUBLIC_CONVEX_URL=https://prod-abc123.convex.cloud - (Use the URL from
npx convex deploy)
- Add
-
Deploy
- Click "Deploy"
- Wait 2-3 minutes
- Get your production URL (e.g.,
https://your-app.vercel.app)
-
Update Convex SITE_URL
npx convex env set SITE_URL https://your-app.vercel.app --prod
# Install Vercel CLI
npm i -g vercel
# Login
vercel login
# Deploy to production
vercel --prod
# Set environment variable
vercel env add NEXT_PUBLIC_CONVEX_URL production
# Enter: https://prod-abc123.convex.cloud- Go to your project in Vercel Dashboard
- Click "Settings" → "Domains"
- Add your domain (e.g.,
myapp.com) - Follow DNS configuration instructions
# Update SITE_URL to your custom domain
npx convex env set SITE_URL https://myapp.com --prodAdd these records to your DNS provider:
Type: A
Name: @
Value: 76.76.21.21
Type: CNAME
Name: www
Value: cname.vercel-dns.com
NEXT_PUBLIC_CONVEX_URL=https://dev-abc123.convex.cloudNEXT_PUBLIC_CONVEX_URL=https://prod-abc123.convex.cloudnpx convex env list
# BETTER_AUTH_SECRET=...
# SITE_URL=http://localhost:3000npx convex env list --prod
# BETTER_AUTH_SECRET=... (different from dev!)
# SITE_URL=https://your-domain.vercel.app- Visit your production URL
- Sign up with a new account
- Verify email/password login works
- Check that protected routes redirect correctly
- Create some data in production
- Open Convex dashboard:
npx convex dashboard --prod - Verify data appears in tables
- Use your app normally
- Check Convex dashboard logs for errors
- Monitor function execution times
Vercel automatically deploys on:
- Push to main branch → Production deployment
- Push to other branches → Preview deployment
Enable automatic Convex deployments:
# Install Convex GitHub Action
# Add to .github/workflows/convex-deploy.ymlname: Deploy Convex
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm install -g convex
- run: npx convex deploy --cmd 'npm install' --cmd-url-env-var-name CONVEX_URL
env:
CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }}# View production logs
npx convex logs --prod
# Tail logs in real-time
npx convex logs --prod --tail- View in Vercel Dashboard → Your Project → Logs
- Or use CLI:
vercel logs
Solution: Verify NEXT_PUBLIC_CONVEX_URL is set correctly in Vercel.
Solution:
- Check
SITE_URLmatches your production domain - Verify
BETTER_AUTH_SECRETis set in production - Clear cookies and try again
Solution:
- Run
npx convex deployto push latest schema - Check Convex dashboard for function errors
- Verify indexes are created
Solution:
- Check build logs in Vercel
- Ensure
package.jsonhas correct dependencies - Try building locally:
pnpm run build
In Vercel Dashboard:
- Go to Deployments
- Find previous successful deployment
- Click "..." → "Promote to Production"
# Convex doesn't support rollback directly
# Redeploy from previous git commit:
git checkout <previous-commit>
npx convex deploy --prod
git checkout mainpnpm add @vercel/analytics// app/layout.tsx
import { Analytics } from "@vercel/analytics/react";
export default function RootLayout({ children }) {
return (
<html>
<body>
{children}
<Analytics />
</body>
</html>
);
}Queries are automatically cached by Convex. No configuration needed!
- Different
BETTER_AUTH_SECRETfor dev and production - HTTPS enabled (automatic with Vercel)
- Environment variables not in code
- No
.env.localin git - CSP headers configured (optional)
- 1GB storage
- 1M function calls/month
- Good for: Small apps, MVPs
- $25/month base
- Additional usage-based pricing
- Good for: Production apps
- Hobby: Free (personal projects)
- Pro: $20/month/user (commercial)
- Set up monitoring (Sentry, LogRocket)
- Configure custom domain
- Enable analytics
- Set up backup strategy
- Plan scaling strategy
Previous: ← Development | Back to README →