Prerequisites
- GitHub repository with DelightBridge code
- Vercel account (free tier works)
- Neon database created and configured
- OAuth credentials from Google Cloud Console
- All environment variables ready
Step 1: Import Project to Vercel
Connect GitHub repository
Go to vercel.com and click Add New Project.Select your DelightBridge repository from GitHub.
Configure project settings
Vercel auto-detects Next.js. Verify these settings:
- Framework Preset: Next.js
- Root Directory:
./(leave default) - Build Command:
pnpm build(auto-detected) - Output Directory:
.next(auto-detected) - Install Command:
pnpm install(auto-detected)
DelightBridge uses pnpm. Vercel automatically detects this from
pnpm-lock.yaml.Configure environment variables
Before deploying, add all required environment variables. Click Environment Variables section and add:Select All Environments (Production, Preview, Development) or configure separately.
Step 2: Configure OAuth Redirect URIs
After deployment, update your Google Cloud Console OAuth settings with production URLs.Add production redirect URIs
Go to Google Cloud Console → APIs & Services → Credentials → Your OAuth 2.0 Client ID. Add these Authorized redirect URIs:your-project.vercel.app with your actual Vercel domain.
You need both redirect URIs:
/api/auth/callback/google- for user authentication (NextAuth)/api/services/oauth/callback- for Gmail service connections
Step 3: Push Database Schema
Vercel deployments need the database schema pushed separately.Option A: Push from local machine
With productionDATABASE_URL in .env.local:
Option B: Use Vercel CLI
Install Vercel CLI:Step 4: Configure Cron Jobs
DelightBridge uses Vercel Cron to automatically sync Gmail messages every 5 minutes.Cron configuration file
The repository includesvercel.json with cron configuration:
path: API route to call (/api/cron/sync-gmail)schedule: Cron expression (every 5 minutes)
Vercel Cron is only available on Pro and Enterprise plans. On the free Hobby plan, crons won’t run automatically.
Cron schedule format
The schedule*/5 * * * * means:
*/5 * * * *- Every 5 minutes*/15 * * * *- Every 15 minutes0 * * * *- Every hour at minute 00 0 * * *- Daily at midnight
Verify cron is running
After deployment:- Go to Vercel dashboard → Your project → Cron Jobs tab
- Verify
/api/cron/sync-gmailis listed - Check Last Run timestamp (may take 5 minutes for first run)
- Click on a run to see logs and status
Manually trigger cron (testing)
You can test the cron endpoint manually:your-project.vercel.appwith your Vercel domainyour-cron-secretwith yourCRON_SECRETvalue
Cron Endpoint Details
How cron sync works
Every 5 minutes, Vercel callsGET /api/cron/sync-gmail, which:
- Authenticates using
CRON_SECRETfrom headers - Fetches all connected Gmail accounts from database
- Selects up to
CRON_SYNC_MAX_ACCOUNTSaccounts (round-robin) - Syncs each account incrementally using Gmail API History
- Updates
last_history_idfor next incremental sync - Returns sync results (succeeded/failed/skipped counts)
Round-robin scheduling
If you have more Gmail accounts thanCRON_SYNC_MAX_ACCOUNTS, the cron job processes them in batches:
Example: 50 accounts, CRON_SYNC_MAX_ACCOUNTS=20
- Run 1 (0:00): Accounts 1-20
- Run 2 (0:05): Accounts 21-40
- Run 3 (0:10): Accounts 41-50
- Run 4 (0:15): Accounts 1-20 (cycle repeats)
Security
The cron endpoint requires authentication viaCRON_SECRET:
- Vercel Cron automatically includes this in request headers
- Manual requests must include:
Authorization: Bearer <CRON_SECRET>, ORx-cron-secret: <CRON_SECRET>
401 Unauthorized.
Environment Variables in Vercel
View and edit variables
- Go to Vercel dashboard → Your project → Settings → Environment Variables
- Edit or add variables as needed
- Click Save
Redeploy after variable changes
Go to Deployments tab → Click ••• on latest deployment → Redeploy. Or trigger a new deployment by pushing to your GitHub repository.Environment-specific variables
You can set different values for:- Production - Live deployment
- Preview - Pull request deployments
- Development - Local development (via
vercel env pull)
Custom Domains
Add custom domain
Configure DNS
Vercel provides DNS instructions:
- Subdomain (recommended): Add CNAME record pointing to
cname.vercel-dns.com - Apex domain: Add A record pointing to Vercel’s IP
DNS changes may take up to 48 hours to propagate.
Deployment Checklist
Before going live:- All environment variables set in Vercel
- Production database schema pushed (
pnpm db:push) - OAuth redirect URIs updated with production domain
- Cron jobs configured and running (Pro plan required)
-
CRON_SECRETset and matches in environment variables -
ADMIN_EMAILScontains production admin emails - Test login flow works
- Test Gmail service connection flow
- Verify cron sync runs successfully
Monitoring and Logs
View application logs
Vercel dashboard → Your project → Deployments → Click deployment → Runtime Logs Filter by:- Source: Edge, Serverless, etc.
- Status: Errors, Warnings, All
View cron logs
Vercel dashboard → Your project → Cron Jobs → Click a run Shows:- Execution time
- Duration
- Status code
- Response body
- Runtime logs
Monitor Gmail API usage
Go to Google Cloud Console → APIs & Services → Dashboard Check quotas for:- Gmail API - Daily quota (usually 1 billion quota units/day)
- Monitor requests/day to avoid hitting limits
Troubleshooting
Build fails with “pnpm not found”
Vercel should auto-detect pnpm frompnpm-lock.yaml. If not:
- Go to Settings → General
- Set Install Command to
pnpm install - Redeploy
”Database connection failed” error
Verify:DATABASE_URLis set correctly in Vercel environment variables- Connection string includes
?sslmode=require - Neon project is not paused (free tier auto-pauses after inactivity)
Cron jobs not running
Verify:- You’re on Vercel Pro or Enterprise plan (Hobby plan doesn’t support cron)
vercel.jsonis committed to repository- Redeploy after adding
vercel.json
”Unauthorized cron request” in logs
Verify:CRON_SECRETis set in Vercel environment variables- Value matches exactly (no extra spaces/newlines)