Overview
The NJ Rajat Mahotsav platform is optimized for deployment on Vercel with Next.js 15. This guide covers the complete deployment process including environment configuration, build settings, and domain management.Prerequisites
Before deploying to Vercel:- GitHub repository with your code pushed
- Vercel account (free tier works for most use cases)
- All environment variables from Environment Setup
- Supabase project configured and running
- Cloudflare R2 bucket created
Deployment Steps
The project uses Next.js 15 with App Router. Vercel automatically detects this configuration from
package.json and next.config.mjs.NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
R2_ENDPOINT=https://your-account-id.r2.cloudflarestorage.com
R2_ACCESS_KEY_ID=your-access-key
R2_SECRET_ACCESS_KEY=your-secret-key
R2_BUCKET_NAME=your-bucket-name
R2_BUCKET_PREFIX=uploads/
Environment Scope:Set environment variables for all environments:
- ✅ Production
- ✅ Preview
- ✅ Development
npm install)npm run build)Build Configuration
The project’snext.config.mjs includes specific configurations for production:
Security Headers
The platform automatically applies security headers to all routes vianext.config.mjs:
Custom Domain Configuration
Cloudflare Integration:If using Cloudflare for DNS, set SSL/TLS mode to Full (not Full Strict) to avoid certificate errors during initial setup.
Supabase OAuth Configuration
Update Supabase OAuth redirect URLs for production:Monitoring and Analytics
The platform includes Vercel Analytics and Speed Insights:- Vercel Dashboard → Analytics
- Speed Insights tab
Environment-Specific Configuration
Production vs Preview Branches
Vercel automatically creates preview deployments for:- Pull requests
- Non-production branches
main or master
Preview Branches: All other branches
Branch-Specific Environment Variables
Use different Supabase projects for preview environments:- Create a staging Supabase project
- In Vercel, set environment variables with scope:
- Production: Production Supabase credentials
- Preview: Staging Supabase credentials
- Development: Local development credentials
Deployment Checklist
Before deploying to production:- All environment variables configured in Vercel
- Admin domain updated in
lib/admin-auth.ts - Supabase OAuth redirect URLs include production domain
- Cloudflare R2 bucket has production credentials
- DNS records configured and propagated
- SSL certificate provisioned (automatic)
- Security headers verified (automatic)
- Test registration form submission
- Test admin portal OAuth flow
- Test file uploads to R2
- Verify Cloudflare CDN assets loading
Continuous Deployment
Vercel automatically deploys on every push to your repository:- Detect the push via GitHub webhook
- Start a new deployment
- Run build and tests
- Deploy to production (if on main branch)
- Send deployment notification
Rollback Deployments
If a deployment causes issues:- Go to Vercel Dashboard → Deployments
- Find the last working deployment
- Click ⋯ → Promote to Production
- Confirm rollback
Performance Optimization
Edge Functions
API routes run on Vercel Edge Network by default. No additional configuration needed.Image Optimization
The project uses Cloudflare Images for optimization:images.unoptimized: true) in favor of Cloudflare’s service.
Build Cache
Vercel automatically caches:node_modules(between builds).next/cache(Next.js build cache)- Static assets
Troubleshooting
Build Failures
Problem: Build fails with “Module not found” Solution:Environment Variable Issues
Problem: “Cannot read property of undefined” in production Solution:- Go to Settings → Environment Variables
- Verify all variables are set for Production scope
- Re-deploy: Deployments → ⋯ → Redeploy
OAuth Redirect Errors
Problem: “redirect_uri mismatch” after Google sign-in Solution:- Add all production URLs to Supabase redirect URLs
- Include both apex and www subdomains
- Wait 5 minutes for Supabase cache to clear
Next Steps
After successful deployment:- Review Security Checklist
- Configure Supabase Row Level Security
- Set up rate limiting
- Enable monitoring alerts
- Configure backup strategy
