Overview
Lawn is designed to deploy seamlessly on Vercel with Convex as the backend. The deployment process automatically handles both the frontend build and Convex deployment in a single step.Prerequisites
Before deploying, ensure you have:- A Vercel account
- A Convex account with a production project
- All required environment variables configured (see Environment Variables)
- Production API keys for Clerk, Mux, and Stripe
Deployment Architecture
Lawn uses a coordinated deployment strategy:- Convex deploys first - Backend functions and database schema
- Frontend builds - Vite builds the application with the Convex deployment URL
- Vercel serves - Static assets and server functions
Deploy to Vercel
Create a Convex production deployment
In your Convex dashboard:
- Navigate to your project at dashboard.convex.dev
- Go to Settings > Deployment Keys
- Click Generate Deploy Key
- Copy the deploy key (you’ll need it in the next step)
Import project to Vercel
- Go to vercel.com/new
- Import your Lawn repository from GitHub
- Select your repository and click Import
Configure build settings
Vercel should auto-detect the settings, but verify:
- Framework Preset: Vite
- Build Command:
bun run build:vercel - Output Directory:
dist - Install Command:
bun install
The
build:vercel script handles both Convex deployment and frontend build.Add environment variables
In your Vercel project settings, go to Settings > Environment Variables and add:Required for deployment:Frontend variables:
Understanding the Build Process
Thebuild:vercel script in package.json runs:
- Deploys your Convex functions to production
- Obtains the production Convex URL
- Sets
VITE_CONVEX_URLto the production URL - Runs
bun run build(Vite build) with the correct URL
This ensures your frontend is built with the exact Convex deployment URL it will use in production.
Configure Convex Environment Variables
After your first deployment, configure environment variables in Convex:Open Convex dashboard
Navigate to your production project at dashboard.convex.dev
Add production environment variables
Go to Settings > Environment Variables and add all backend secrets:
Configure Webhooks
Update your webhook URLs in Mux and Stripe to point to your production Convex deployment.Mux Webhooks
Open Mux dashboard
Go to mux.com
Update webhook URL
Navigate to Settings > Webhooks and update (or create) a webhook:Ensure these events are enabled:
video.asset.readyvideo.asset.errored
Stripe Webhooks
Open Stripe dashboard
Go to stripe.com/dashboard
Update webhook URL
Navigate to Developers > Webhooks and add a new endpoint:Listen for these events:
customer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_succeededinvoice.payment_failed
Domain Configuration
Add custom domain in Vercel
Go to Settings > Domains in your Vercel project and add your custom domain.
Update Clerk allowed origins
In your Clerk dashboard, go to Settings > Domains and add your production domain to the allowed origins.
Continuous Deployment
Vercel automatically deploys when you push to your repository:- Production branch (usually
main) - Deploys to production - Other branches - Creates preview deployments
Preview deployments can use the same Convex development environment, or you can create separate Convex projects for staging.
Production Checklist
Before going live, verify:- All environment variables are set with production keys
-
CONVEX_DEPLOY_KEYis configured in Vercel - Convex environment variables are configured in Convex dashboard
- Mux webhook points to production Convex URL
- Stripe webhook points to production Convex URL
- Custom domain is configured and SSL is active
- Clerk allows your production domain
- Test user signup and authentication
- Test video upload and processing
- Test subscription creation and webhooks
Monitoring and Logs
Vercel Logs
View deployment and runtime logs:- Go to your project in Vercel
- Click on a deployment
- View Build Logs or Function Logs
Convex Logs
View backend function logs:- Go to dashboard.convex.dev
- Select your production project
- Click Logs in the sidebar
Convex logs include all console output from your backend functions, including errors and debugging information.
Troubleshooting
Build Failures
If the build fails:- Check that
CONVEX_DEPLOY_KEYis set correctly - Verify Convex environment variables are configured
- Check Vercel build logs for specific errors
- Ensure all dependencies are in
package.json
Webhook Failures
If webhooks aren’t working:- Verify webhook URLs point to your production Convex site
- Check webhook secrets match in both service and Convex
- View webhook delivery logs in Mux/Stripe dashboards
- Check Convex logs for webhook handler errors
Authentication Issues
If users can’t sign in:- Verify
VITE_CLERK_PUBLISHABLE_KEYuses production key - Ensure your domain is allowed in Clerk settings
- Check that
CLERK_SECRET_KEYis set in Convex - Verify JWT issuer domain matches
Video Processing Issues
If videos aren’t processing:- Check Mux webhook is configured correctly
- Verify Mux credentials in Convex environment variables
- Check Convex logs for Mux API errors
- Ensure signing keys are configured for playback
Updating Production
To deploy updates:- Push changes to your production branch
- Vercel automatically builds and deploys
- Convex deploys as part of the build process
- Monitor logs for any errors
Rollback
If you need to rollback a deployment:Rollback frontend
In Vercel, go to your project’s Deployments page and click Promote to Production on a previous deployment.
Next Steps
Installation
Set up Lawn for local development
Environment Variables
Complete guide to all environment variables
