Skip to main content

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

1
Step 1: Connect GitHub Repository
2
  • Log in to Vercel Dashboard
  • Click Add New…Project
  • Import your GitHub repository:
    https://github.com/your-username/Rajat-Mahotsav-Website
    
  • Click Import
  • 3
    Step 2: Configure Project Settings
    4
    Vercel will auto-detect Next.js. Verify these settings:
    5
    Framework Preset: Next.js
    6
    Root Directory: ./ (leave as default)
    7
    Build Command:
    8
    npm run build
    
    9
    Output Directory: .next (auto-configured)
    10
    Install Command:
    11
    npm install
    
    12
    The project uses Next.js 15 with App Router. Vercel automatically detects this configuration from package.json and next.config.mjs.
    13
    Step 3: Add Environment Variables
    14
    Click Environment Variables section and add all required variables:
    15
    Supabase Variables
    16
    NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
    NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
    
    17
    Cloudflare R2 Variables
    18
    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/
    
    19
    Environment Scope:Set environment variables for all environments:
    • ✅ Production
    • ✅ Preview
    • ✅ Development
    This ensures preview deployments and local development via Vercel CLI work correctly.
    20
    Step 4: Deploy
    21
    Click Deploy to start the build process.
    22
    Vercel will:
    23
  • Clone your repository
  • Install dependencies (npm install)
  • Run the build command (npm run build)
  • Deploy to a production URL
  • 24
    Initial deployment takes 2-5 minutes.

    Build Configuration

    The project’s next.config.mjs includes specific configurations for production:
    const nextConfig = {
      eslint: {
        ignoreDuringBuilds: true,
      },
      typescript: {
        ignoreBuildErrors: true,
      },
      images: {
        unoptimized: true
      },
      experimental: {
        optimizePackageImports: ['framer-motion'],
      },
    }
    
    Production Recommendations:Before going live, fix TypeScript and ESLint errors:
    eslint: {
      ignoreDuringBuilds: false, // Enable linting
    },
    typescript: {
      ignoreBuildErrors: false, // Enable type checking
    },
    
    These are currently disabled for rapid development but should be addressed for production stability.

    Security Headers

    The platform automatically applies security headers to all routes via next.config.mjs:
    async headers() {
      return [
        {
          source: '/(.*)',
          headers: [
            {
              key: 'X-Frame-Options',
              value: 'DENY',
            },
            {
              key: 'X-Content-Type-Options',
              value: 'nosniff',
            },
            {
              key: 'X-XSS-Protection',
              value: '1; mode=block',
            },
            {
              key: 'Referrer-Policy',
              value: 'strict-origin-when-cross-origin',
            },
            {
              key: 'Permissions-Policy',
              value: 'camera=(), microphone=(), geolocation=()',
            },
          ],
        },
      ]
    }
    
    These headers are automatically deployed with your application. No additional configuration needed in Vercel.

    Custom Domain Configuration

    1
    Step 1: Add Domain in Vercel
    2
  • Go to your project in Vercel Dashboard
  • Navigate to SettingsDomains
  • Click Add and enter your domain:
    njrajatmahotsav.com
    www.njrajatmahotsav.com
    
  • 3
    Step 2: Configure DNS Records
    4
    Add these records in your domain registrar (e.g., Cloudflare DNS):
    5
    For apex domain (njrajatmahotsav.com):
    6
    Type: A
    Name: @
    Value: 76.76.21.21
    
    7
    For www subdomain:
    8
    Type: CNAME
    Name: www
    Value: cname.vercel-dns.com
    
    9
    Step 3: Wait for DNS Propagation
    10
    DNS changes take 1-48 hours to propagate globally. Check status:
    11
    nslookup njrajatmahotsav.com
    
    12
    Step 4: Enable HTTPS
    13
    Vercel automatically provisions SSL certificates via Let’s Encrypt. This happens within minutes after DNS verification.
    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:
    1
    Step 1: Add Production URLs
    2
  • Go to Supabase Dashboard → AuthenticationURL Configuration
  • Add to Redirect URLs:
    https://njrajatmahotsav.com/auth/callback
    https://www.njrajatmahotsav.com/auth/callback
    https://your-project.vercel.app/auth/callback
    
  • 3
    Step 2: Configure Site URL
    4
    Set Site URL to your primary domain:
    5
    https://njrajatmahotsav.com
    
    6
    Step 3: Test OAuth Flow
    7
  • Navigate to https://your-domain.com/admin/registrations
  • Click Sign in with Google
  • Verify successful redirect after authentication
  • Security Note:The admin portal restricts access by email domain (@nj.sgadi.us). Update this in lib/admin-auth.ts before deployment:
    const ALLOWED_DOMAIN = "@your-organization.com"
    

    Monitoring and Analytics

    The platform includes Vercel Analytics and Speed Insights:
    {
      "dependencies": {
        "@vercel/analytics": "1.3.1",
        "@vercel/speed-insights": "^1.3.1"
      }
    }
    
    These are automatically enabled in production. View metrics in:
    • Vercel DashboardAnalytics
    • Speed Insights tab

    Environment-Specific Configuration

    Production vs Preview Branches

    Vercel automatically creates preview deployments for:
    • Pull requests
    • Non-production branches
    Production Branch: main or master Preview Branches: All other branches

    Branch-Specific Environment Variables

    Use different Supabase projects for preview environments:
    1. Create a staging Supabase project
    2. 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:
    git add .
    git commit -m "Update feature"
    git push origin main
    
    Vercel will:
    1. Detect the push via GitHub webhook
    2. Start a new deployment
    3. Run build and tests
    4. Deploy to production (if on main branch)
    5. Send deployment notification

    Rollback Deployments

    If a deployment causes issues:
    1. Go to Vercel DashboardDeployments
    2. Find the last working deployment
    3. Click Promote to Production
    4. Confirm rollback
    The previous deployment becomes active immediately.

    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:
    // lib/cdn-assets.ts helpers
    getCloudflareImage(imageId: string, variant?: string)
    getCloudflareImageMobileWp(imageId: string)
    getCloudflareImageBiggest(imageId: string)
    
    Next.js image optimization is disabled (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
    This reduces build times from 5 minutes to ~30 seconds for subsequent deployments.

    Troubleshooting

    Build Failures

    Problem: Build fails with “Module not found” Solution:
    # Verify dependencies in package.json
    npm install
    npm run build
    
    Test locally before pushing.

    Environment Variable Issues

    Problem: “Cannot read property of undefined” in production Solution:
    1. Go to SettingsEnvironment Variables
    2. Verify all variables are set for Production scope
    3. Re-deploy: DeploymentsRedeploy

    OAuth Redirect Errors

    Problem: “redirect_uri mismatch” after Google sign-in Solution:
    1. Add all production URLs to Supabase redirect URLs
    2. Include both apex and www subdomains
    3. Wait 5 minutes for Supabase cache to clear

    Next Steps

    After successful deployment:
    1. Review Security Checklist
    2. Configure Supabase Row Level Security
    3. Set up rate limiting
    4. Enable monitoring alerts
    5. Configure backup strategy

    Build docs developers (and LLMs) love