Overview
This guide covers deploying Agora to production, with a focus on Vercel deployment (the recommended platform), along with environment setup, database migrations, and monitoring configuration.Agora is built on Next.js 14 and optimized for deployment on Vercel, the platform from the creators of Next.js.
Pre-Deployment Checklist
Before deploying, ensure you have:Production environment variables
Prepare all required environment variables for production. See the Configuration Guide for the complete list.
Minimum required variables:
NEXT_PUBLIC_AGORA_INSTANCE_NAMENEXT_PUBLIC_AGORA_INSTANCE_TOKENNEXT_PUBLIC_AGORA_ENV=prodNEXT_PUBLIC_ALCHEMY_IDSERVERSIDE_ALCHEMY_ID_PRODNEXT_PUBLIC_WALLETCONNECT_PROJECT_IDREAD_WRITE_WEB2_DATABASE_URL_PRODREAD_ONLY_WEB3_DATABASE_URL_PRODJWT_SECRETNEXT_PUBLIC_AGORA_BASE_URL
Production database
Set up production PostgreSQL databases:
- Web2 database for user-generated content
- Web3 database for blockchain indexed data
Vercel Deployment
Vercel is the recommended deployment platform for Agora.Initial Setup
Create Vercel account
Sign up at vercel.com if you haven’t already.
Connect repository
Option 1: Via Vercel DashboardFollow the prompts to link your repository.
- Go to Vercel Dashboard
- Click “Import Project”
- Select your Git provider (GitHub, GitLab, Bitbucket)
- Choose your Agora repository
- Vercel will auto-detect Next.js configuration
Configure environment variables
In the Vercel dashboard:
- Go to Project Settings → Environment Variables
- Add all production environment variables
- Set the environment scope:
- Production for production deployments
- Preview for pull request previews
- Development for local development
Configure build settings
Vercel auto-detects Next.js projects, but verify:
- Framework Preset: Next.js
- Build Command:
npm run build(ornext build) - Output Directory:
.next - Install Command:
npm install - Development Command:
npm run dev
These are usually auto-configured correctly for Next.js projects.
Custom Domain Setup
Add domain in Vercel
- Go to Project Settings → Domains
- Click “Add Domain”
- Enter your domain (e.g.,
vote.ens.domains)
Configure DNS
Vercel will provide DNS configuration:Option 1: Using Vercel nameservers (recommended)Option 3: Using A record
- Point your domain’s nameservers to Vercel
- Vercel manages SSL automatically
Wait for SSL provisioning
Vercel automatically provisions SSL certificates. This usually takes a few minutes.
Your site will be available at
https://your-domain.com once SSL is active.Automatic Vercel Environment Variables
Vercel automatically sets these variables (used for monitoring):VERCEL_ENV- Environment type (production/preview/development)VERCEL_URL- Deployment URLVERCEL_REGION- Deployment regionVERCEL_GIT_COMMIT_SHA- Git commit SHAVERCEL_BRANCH_URL- Branch-specific URL
These are used by Agora’s OpenTelemetry integration for tracing. Do not override them.
Environment Setup for Production
Database Configuration
Provision production databases
Set up two PostgreSQL databases:Recommended providers:
- Supabase - Postgres with built-in features
- Neon - Serverless Postgres
- AWS RDS - Managed PostgreSQL
- Google Cloud SQL - Managed databases
- Web2 database: User content, requires read-write access
- Web3 database: Indexed blockchain data, read-only access
API Keys and Services
Alchemy Configuration
Alchemy Configuration
Set up separate Alchemy API keys:In Alchemy Dashboard:
- Create two API keys (client and server)
- For client key: Add your domain to whitelist
- For server key: No restrictions needed
- Monitor usage to stay within limits
WalletConnect Setup
WalletConnect Setup
Configure WalletConnect for production:In WalletConnect Cloud:
- Create a production project
- Add your domain to allowed origins
- Copy the Project ID
External Services
External Services
Configure optional external services:Tenderly (Transaction Simulation):Pinata (IPFS):Etherscan:
Security Keys
Security Keys
Generate and securely store sensitive keys:JWT Secret:Gas Sponsor Private Key:EAS Sender Private Key:
Database Migrations
The database schema is managed in a separate repository.Migration Process
Pull latest schema
On your local machine:This introspects the production database and updates your Prisma schema.
For more details on database management, see the Database Manual.
Monitoring and Observability
Agora includes built-in OpenTelemetry (OTel) integration for monitoring.OpenTelemetry Setup
OpenTelemetry is automatically configured when deploying to Vercel. Configuration file:instrumentation.ts (or instrumentation.js)
The instrumentation file is automatically loaded by Next.js 14+ when present in the project root.
DataDog Integration
Optionally integrate with DataDog for metrics and monitoring:Get DataDog credentials
Sign up at DataDog and get:
- API Key
- Application Key
Vercel Analytics
Agora includes Vercel Analytics and Speed Insights:- Page views
- Core Web Vitals (LCP, FID, CLS)
- User interactions
- Performance data
Monitoring Best Practices
Monitor these key metrics:
-
Database Performance
- Query response times
- Connection pool usage
- Slow query logs
-
API Performance
- Response times for
/api/*routes - Error rates
- Rate limiting metrics
- Response times for
-
Blockchain RPC
- Alchemy API usage and rate limits
- RPC call success rates
- Block synchronization lag
-
User Experience
- Core Web Vitals
- Page load times
- Error tracking
-
Security
- Failed authentication attempts
- Suspicious activity patterns
- API key usage anomalies
Production Optimization
Performance Optimization
Enable caching
Enable caching
Configure caching for static assets and API responses:In
next.config.js:Optimize images
Optimize images
Use Next.js Image optimization:Vercel automatically optimizes images on-demand.
Database connection pooling
Database connection pooling
Use connection pooling to prevent connection exhaustion:
- Configure
connection_limitin Prisma - Use PgBouncer or Supabase Pooler
- Monitor active connections
Bundle size optimization
Bundle size optimization
Analyze and optimize bundle size:This uses
@next/bundle-analyzer to visualize bundle composition.Optimization techniques:- Dynamic imports for large components
- Tree shaking unused code
- Minimize third-party dependencies
Security Hardening
Rotate secrets regularly
Establish a secret rotation schedule:
- JWT secrets: Every 90 days
- Private keys: Every 180 days
- API keys: Monitor and rotate if compromised
Deployment Checklist
Before going live, verify:
- All environment variables are set in Vercel
- Production databases are configured and accessible
- SSL certificates are provisioned
- Custom domain is configured
- Database migrations are applied
- Monitoring is configured (OpenTelemetry, DataDog)
- Analytics are enabled (Vercel Analytics)
- Security headers are configured
- API keys are whitelisted (Alchemy, WalletConnect)
- Build completes without errors
- Application functions correctly on production URL
- Wallet connection works
- Proposal voting works
- Database queries execute successfully
Rollback Strategy
Vercel Rollback
Via Vercel Dashboard
- Go to Deployments
- Find the last working deployment
- Click ⋯ → Promote to Production
Troubleshooting
Build fails on Vercel
Build fails on Vercel
Common causes:
- Missing environment variables
- TypeScript errors
- Dependency issues
- Check build logs in Vercel dashboard
- Run
npm run buildlocally to reproduce - Fix errors and redeploy
Database connection fails
Database connection fails
Verify:
- Database is accessible from Vercel’s IP ranges
- Connection strings are correct
- SSL is configured if required
- Connection pool limits are not exceeded
Environment variables not updating
Environment variables not updating
Redeploy after changing environment variables:
- Update variables in Vercel dashboard
- Go to Deployments
- Click Redeploy on the latest deployment
Slow API responses
Slow API responses
Diagnose:
- Check database query performance
- Monitor RPC call times (Alchemy)
- Review Vercel function logs
- Add database indexes
- Implement caching (Redis/Upstash)
- Use connection pooling
Next Steps
Architecture
Understand the system architecture
Customization
Customize your deployed instance
Configuration
Environment variables and settings
Setup Guide
Initial setup and prerequisites