Vercel Environment Variables Setup
🚨 Required for Deployment
The following environment variables must be configured in Vercel to resolve build errors:
1. Database Configuration (CRITICAL)
Variable: DATABASE_URL
Value: Your PostgreSQL database connection string
Environment: Production, Preview, Development
Error if missing: Error: Environment variable not found: DATABASE_URL
Get your DATABASE_URL from:
Vercel Postgres: Create database in Vercel dashboard → Copy connection string
Supabase: Project Settings → Database → Connection String → URI
Railway: PostgreSQL service → Connect tab → Postgres Connection URL
Neon: Project created → Copy connection string
Format: postgresql://username:password@host:port/database?sslmode=require
Detailed setup guide: See DATABASE_SETUP.md
2. Authentication (CRITICAL)
Variables:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
CLERK_SECRET_KEY
Value: Your Clerk API keys from Clerk Dashboard Environment: Production, Preview, Development Error if missing: Build succeeds but authentication fails at runtime
How to get:
1. Sign up at clerk.com
2. Create an application
3. Go to API Keys section
4. Copy both keys
5. Use production keys (pk_live_... and sk_live_...) for production deployment
3. Stripe Configuration (REQUIRED for payments)
Variable: STRIPE_SECRET_KEY
Value: Your actual Stripe secret key from Stripe Dashboard
Environment: Production, Preview, Development
Error if missing: Neither apiKey nor config.authenticator provided
🔧 How to Add Environment Variables in Vercel
Method 1: Vercel Dashboard
1. Go to your project in Vercel Dashboard 2. Navigate to Settings → Environment Variables 3. Click Add New 4. Enter:
Name: STRIPE_SECRET_KEY
Value: sk_live_... (your actual key)
Environments: Check all (Production, Preview, Development)
5. Click Save
Method 2: Vercel CLI
# Add environment variable
vercel env add STRIPE_SECRET_KEY
# List current environment variables
vercel env ls
# Pull environment variables to local .env.local
vercel env pull .env.localMethod 3: vercel.json Configuration
{
"env": {
"STRIPE_SECRET_KEY": "@stripe-secret-key"
}
}🔍 Common Build/Deployment Errors
Error 1: Missing DATABASE_URL
Error Message:
Error: Prisma schema validation - (get-config wasm)
Error code: P1012
error: Environment variable not found: DATABASE_URL.
--> prisma/schema.prisma:7Root Cause: Missing DATABASE_URL environment variable
Files Affected: All database operations, build process
Severity: 🚨 BLOCKS DEPLOYMENT - Build will fail completely
Solution:
1. Set up a database (see DATABASE_SETUP.md)
2. Add DATABASE_URL to Vercel environment variables
3. Redeploy
Error 2: Missing Stripe Keys
Error Message: Neither apiKey nor config.authenticator provided
Files Affected:
/api/book/[bookId]/route.ts
/api/book/payment-intent/route.ts
Root Cause: Missing STRIPE_SECRET_KEY environment variable
Severity: ⚠️ Blocks payment functionality, but build succeeds
Solution:
1. Get API key from Stripe Dashboard
2. Add STRIPE_SECRET_KEY to Vercel
3. Redeploy
Error 3: Authentication Issues
Error Message: Various Clerk-related errors at runtime Root Cause: Missing or invalid Clerk API keys Severity: ⚠️ Build succeeds but login/signup fails
Solution:
1. Get keys from Clerk Dashboard
2. Add both NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY
3. Ensure using production keys for production environment
4. Redeploy
✅ Verification Steps
After adding the environment variable:
1. Trigger New Deployment:
git push origin main2. Check Build Status:
Monitor deployment in Vercel Dashboard
Check GitHub Actions TypeCheck workflow
Verify no "apiKey" errors in build logs
3. Test Payment Routes:
Verify /api/book/payment-intent responds without errors
Check book claiming functionality
🔒 Security Notes
Never commit actual Stripe keys to git
Use test keys (sk_test_) for development/preview
Use live keys (sk_live_) only for production
Rotate keys regularly as security best practice
📋 Environment Variables Checklist
Critical (Required for Build)
[ ] DATABASE_URL - MUST BE SET or deployment fails
[ ] NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY - Required for auth
[ ] CLERK_SECRET_KEY - Required for auth
Required for Functionality
[ ] STRIPE_SECRET_KEY - Required for payments
Optional
[ ] SLACK_WEBHOOK_URL - For problem worksheet Slack notifications
[ ] SLACK_WEBHOOK_URL_CHAT - For chat messages and book claim notifications
[ ] - DEPRECATED (replaced by webhooks)SLACK_TOKEN
[ ] GOOGLE_SHEETS_ID - For Google Sheets integration
[ ] GOOGLE_SERVICE_ACCOUNT_EMAIL - For Google API auth
[ ] FOUNDER_USER_ID - Admin user identification
[ ] GITHUB_PRIVATE_REPO - Private repo access
Post-Setup
[ ] Redeploy after adding variables
[ ] Verify build success (check logs)
[ ] Test authentication (login/signup)
[ ] Test payment functionality (if using Stripe)
[ ] Test database connectivity (check pages load)
🎯 Expected Results
After configuration:
✅ Vercel deployments will succeed
✅ Build errors will be resolved
✅ Database migrations will apply automatically
✅ Authentication will work (login/signup)
✅ TypeCheck workflow will show clean status
✅ Book payment system will be functional
📚 Additional Resources
DATABASE_SETUP.md - Comprehensive database setup guide
DEPLOYMENT.md - Complete deployment walkthrough
.env.example - All environment variables with examples
Vercel Docs - Official Vercel documentation