Documentation Index
Fetch the complete documentation index at: https://mintlify.com/voteagora/agora-next/llms.txt
Use this file to discover all available pages before exploring further.
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.Pre-Deployment Checklist
Before deploying, ensure you have:Production environment 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
- 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
Connect 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
- 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
- Framework Preset: Next.js
- Build Command:
npm run build(ornext build) - Output Directory:
.next - Install Command:
npm install - Development Command:
npm run dev
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
- Point your domain’s nameservers to Vercel
- Vercel manages SSL automatically
Wait for SSL provisioning
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
Environment Setup for Production
Database Configuration
Provision production databases
- 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
- 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
- Create a production project
- Add your domain to allowed origins
- Copy the Project ID
External Services
External Services
Security Keys
Security Keys
Database Migrations
The database schema is managed in a separate repository.Migration Process
Pull latest schema
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)
DataDog Integration
Optionally integrate with DataDog for metrics and monitoring:Get DataDog credentials
- 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
-
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
next.config.js:Optimize images
Optimize images
Database connection pooling
Database connection pooling
- Configure
connection_limitin Prisma - Use PgBouncer or Supabase Pooler
- Monitor active connections
Bundle size optimization
Bundle size optimization
@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
- JWT secrets: Every 90 days
- Private keys: Every 180 days
- API keys: Monitor and rotate if compromised
Deployment Checklist
- 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
- 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
- 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
- Update variables in Vercel dashboard
- Go to Deployments
- Click Redeploy on the latest deployment
Slow API responses
Slow API responses
- Check database query performance
- Monitor RPC call times (Alchemy)
- Review Vercel function logs
- Add database indexes
- Implement caching (Redis/Upstash)
- Use connection pooling