Skip to main content
Evaly is designed to be deployed to Cloudflare Workers for optimal performance and global edge deployment. This guide covers deploying both the frontend and backend.

Deployment Architecture

Evaly uses a split deployment architecture:
  • Frontend: Deployed to Cloudflare Workers (serverless edge computing)
  • Backend: Deployed to Convex (serverless backend platform)
  • File Storage: Cloudflare R2 (object storage)
The frontend and backend are deployed independently. This allows you to update each component without affecting the other.

Prerequisites

Before deploying, ensure you have:

Backend Deployment (Convex)

1

Set Production Environment Variables

Configure all required environment variables for production. Make sure to update URLs and use production credentials:
# Update SITE_URL for production
npx convex env set SITE_URL https://yourdomain.com --prod

# Set all other required variables
npx convex env set AUTH_GOOGLE_ID <prod-client-id> --prod
npx convex env set AUTH_GOOGLE_SECRET <prod-client-secret> --prod

# Configure production R2 bucket
npx convex env set R2_BUCKET evaly-uploads-prod --prod
npx convex env set R2_CDN_URL https://cdn.yourdomain.com --prod
# ... set all other R2 variables

# Configure email and AI services
npx convex env set PLUNK_SECRET_API_KEY <prod-key> --prod
npx convex env set GOOGLE_GENERATIVE_AI_API_KEY <prod-key> --prod
Use the --prod flag to set environment variables specifically for production.
2

Deploy to Convex

Deploy your Convex backend to production:
npx convex deploy --prod
This will:
  • Push all functions from the convex/ directory
  • Update database schemas
  • Set up scheduled functions (crons)
  • Deploy all Convex components (R2, presence, agent, polar)
3

Verify Deployment

Check the deployment status in the Convex Dashboard:
  • Verify all functions are deployed
  • Check that database tables are created
  • Ensure environment variables are set correctly
  • Review deployment logs for any errors

Frontend Deployment (Cloudflare Workers)

1

Configure Cloudflare

Install Wrangler CLI if you haven’t already:
npm install -g wrangler
Authenticate with Cloudflare:
wrangler login
This will open a browser window for you to log in to your Cloudflare account.
2

Update Frontend Environment

Update your .env.local file to point to your production Convex deployment:
.env.local
CONVEX_DEPLOYMENT=your-production-deployment-name
Make sure this matches your production Convex deployment, not your development one.
3

Update Wrangler Configuration

Review your wrangler.jsonc configuration:
wrangler.jsonc
{
  "$schema": "node_modules/wrangler/config-schema.json",
  "name": "evaly-io",
  "compatibility_date": "2025-10-11",
  "compatibility_flags": ["nodejs_compat"],
  "main": "@tanstack/react-start/server-entry",
  "observability": {
    "enabled": true
  }
}
You can customize:
  • name: Your worker name (used in the Cloudflare dashboard)
  • compatibility_date: The date for Cloudflare Workers API compatibility
  • observability: Enable/disable monitoring and analytics
4

Build and Deploy

Deploy the frontend to Cloudflare Workers:
bun run deploy
This single command will:
  1. Build the application with Vite (vite build)
  2. Generate a sitemap for SEO (bun run generate:sitemap)
  3. Deploy to Cloudflare Workers (wrangler deploy)
You can also run each step individually:
# Build the application
bun run build

# Generate sitemap
bun run generate:sitemap

# Deploy to Cloudflare
wrangler deploy
5

Configure Custom Domain (Optional)

To use a custom domain:
  1. Go to your Cloudflare Dashboard
  2. Navigate to Workers & Pages > Your worker
  3. Go to Settings > Domains & Routes
  4. Click Add Custom Domain
  5. Enter your domain (e.g., evaly.io)
  6. Cloudflare will automatically configure DNS if your domain is managed by Cloudflare
If your domain is not managed by Cloudflare, you’ll need to add CNAME records manually.

Deployment Scripts

Evaly provides several npm scripts for deployment:
# Build, generate sitemap, and deploy to Cloudflare
bun run deploy

Environment-Specific Deployments

Development/Staging

For staging deployments, you can use a separate Cloudflare Worker:
# Deploy to staging worker
wrangler deploy --env staging
Create a wrangler.staging.jsonc for staging-specific configuration.

Production

Always use the --prod flag for production Convex deployments:
# Deploy backend to production
npx convex deploy --prod

# Deploy frontend to production (default)
bun run deploy

Post-Deployment Checklist

After deploying, verify the following:
1

Test Authentication

  • Test Google OAuth login flow
  • Verify redirects work correctly
  • Check user session persistence
2

Test File Uploads

  • Upload an image in the question editor
  • Verify files are stored in R2
  • Check that uploaded files are publicly accessible via CDN
3

Test Email Delivery

  • Send a test invitation
  • Trigger a password reset
  • Verify emails are delivered successfully
4

Test Real-Time Features

  • Create a test and monitor participants
  • Verify presence tracking works
  • Check that notifications appear in real-time
5

Monitor Performance

  • Check Cloudflare Analytics for edge performance
  • Review Convex Dashboard for function execution times
  • Monitor error rates and logs

Monitoring and Observability

Cloudflare Workers

Cloudflare provides built-in observability:
  1. Go to Workers & Pages in Cloudflare Dashboard
  2. Select your worker
  3. View metrics:
    • Request volume
    • Success/error rates
    • CPU time
    • Response times
Enable Real-Time Logs for debugging:
wrangler tail

Convex Backend

Monitor your Convex deployment:
  1. Visit Convex Dashboard
  2. Select your production deployment
  3. Review:
    • Function execution metrics
    • Database query performance
    • Real-time connection count
    • Error logs
Stream production logs:
npx convex logs --prod

Continuous Deployment

GitHub Actions

Create a GitHub Actions workflow for automated deployments:
.github/workflows/deploy.yml
name: Deploy to Production

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Setup Bun
        uses: oven-sh/setup-bun@v1
      
      - name: Install dependencies
        run: bun install
      
      - name: Deploy Convex Backend
        run: npx convex deploy --prod
        env:
          CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }}
      
      - name: Build and Deploy Frontend
        run: bun run deploy
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
Generate a Convex deploy key from your Convex Dashboard under Settings → Deploy Keys.

Rollback Procedure

If you need to rollback a deployment:

Frontend Rollback

# List previous deployments
wrangler deployments list

# Rollback to a specific deployment
wrangler rollback [deployment-id]

Backend Rollback

Convex doesn’t support direct rollbacks, but you can:
  1. Revert your Git repository to the previous commit
  2. Run npx convex deploy --prod to redeploy the old version

Performance Optimization

Build Optimization

The Vite build is already optimized, but you can further improve it:
  • Enable compression in Cloudflare (automatic)
  • Configure caching headers for static assets
  • Use Cloudflare’s CDN for global distribution

Database Optimization

Convex automatically optimizes queries, but consider:
  • Adding indexes for frequently queried fields
  • Using pagination for large datasets
  • Implementing soft deletes (already done in Evaly)

Troubleshooting

Deployment Fails

Build errors:
  • Run bun run typecheck to catch TypeScript errors
  • Ensure all dependencies are installed with bun install
Wrangler authentication issues:
  • Run wrangler login to re-authenticate
  • Check API token permissions in Cloudflare Dashboard

Runtime Errors

OAuth redirect issues:
  • Verify SITE_URL matches your production domain
  • Check OAuth redirect URIs in Google Cloud Console
File upload errors:
  • Verify R2 bucket permissions
  • Check R2_CDN_URL is publicly accessible
  • Review R2 CORS configuration
Real-time features not working:
  • Check WebSocket connections in browser DevTools
  • Verify Convex deployment is running
  • Review Convex logs for errors

Security Considerations

Always use HTTPS in production. Cloudflare Workers automatically provide SSL/TLS certificates.
  • Rotate API keys regularly
  • Use separate credentials for production and development
  • Enable Cloudflare’s security features (WAF, DDoS protection)
  • Review Convex function permissions
  • Implement rate limiting for sensitive operations

Cost Optimization

Cloudflare Workers

  • Free Tier: 100,000 requests/day
  • Workers Paid: $5/month for 10 million requests

Convex

  • Starter: Free tier with generous limits
  • Professional: Pay-as-you-go for larger deployments
Monitor usage in both dashboards to optimize costs.

Next Steps

Build docs developers (and LLMs) love