poll-application

πŸš€ Production Deployment Guide for Vercel

This guide will help you deploy your Poll Application to Vercel with proper production configuration.

πŸ“‹ Pre-Deployment Checklist

πŸ”§ Step 1: Environment Variables Setup

Get Your Supabase Credentials

  1. Visit Supabase Dashboard: https://app.supabase.com/project/lymdzzecuwprowhuvnku/settings/api
  2. Collect these values:
    • Project URL: https://lymdzzecuwprowhuvnku.supabase.co
    • Anon Key: Copy the anon public key
    • Service Role Key: Copy the service_role key (keep this secret!)

Generate NextAuth Secret

# Generate a secure random secret (32+ characters)
openssl rand -base64 32

Or use an online generator: https://generate-secret.vercel.app/32

🌐 Step 2: Vercel Deployment

Deploy with Vercel

Option B: Manual Deployment

  1. Connect Repository:
    • Go to Vercel Dashboard
    • Click β€œAdd New” β†’ β€œProject”
    • Import your GitHub repository: amitesh-maurya/poll-application
  2. Configure Build Settings:
    • Framework Preset: Next.js
    • Build Command: npm run build (default)
    • Output Directory: .next (default)
    • Install Command: npm install (default)

βš™οΈ Step 3: Environment Variables Configuration

In your Vercel project settings, add these environment variables:

Required Variables

Variable Value Description
NEXTAUTH_SECRET your-generated-32-char-secret NextAuth.js encryption secret
NEXT_PUBLIC_SUPABASE_URL https://lymdzzecuwprowhuvnku.supabase.co Supabase project URL
NEXT_PUBLIC_SUPABASE_ANON_KEY your-supabase-anon-key Supabase anonymous key
SUPABASE_SERVICE_ROLE_KEY your-supabase-service-key Supabase service role key

Production-Specific Variables

Variable Value Description
ALLOW_UNCONFIRMED_EMAIL false Require email confirmation
NODE_ENV production Environment mode
NEXT_PUBLIC_SITE_URL https://your-app.vercel.app Your deployed URL

How to Add Variables in Vercel:

  1. Go to your project dashboard
  2. Click Settings tab
  3. Click Environment Variables in sidebar
  4. Add each variable with these settings:
    • Environment: All (Production, Preview, Development)
    • Type: Plain Text
    • Value: Your actual values

πŸ—„οΈ Step 4: Database Setup

Apply Database Schema

  1. Open Supabase SQL Editor: https://app.supabase.com/project/lymdzzecuwprowhuvnku/sql/new
  2. Copy and run the schema from database-schema.sql:
-- Run the complete schema from database-schema.sql
-- This creates all necessary tables, indexes, and security policies

Verify Database Setup

Check that these tables exist:

πŸ” Step 5: Authentication Configuration

Supabase Auth Settings

  1. Go to Authentication Settings: https://app.supabase.com/project/lymdzzecuwprowhuvnku/auth/settings
  2. Configure Site URL:
    • Add your Vercel URL: https://your-app.vercel.app
    • Add redirect URLs: https://your-app.vercel.app/auth/**

Email Templates (Optional)

Customize email templates in Supabase for:

πŸš€ Step 6: Deploy

  1. Trigger Deployment:
    • Push code to your main branch, or
    • Click β€œDeploy” in Vercel dashboard
  2. Monitor Build:
    • Watch the build logs in Vercel
    • Ensure no errors during build process
  3. Test Deployment:
    • Visit your deployed URL
    • Test signup/signin functionality
    • Create a test poll
    • Verify voting works

βœ… Step 7: Post-Deployment Verification

Production Checklist

Performance Testing

πŸ› Troubleshooting

Common Issues

  1. Build Failures:
    # Check for TypeScript errors
    npm run type-check
       
    # Check for linting issues  
    npm run lint
    
  2. Authentication Issues:
    • Verify NEXTAUTH_SECRET is set and 32+ characters
    • Check NEXTAUTH_URL matches your deployed URL
    • Confirm Supabase auth settings allow your domain
  3. Database Connection Issues:
    • Verify Supabase keys are correct
    • Check RLS policies are properly configured
    • Ensure database schema is applied
  4. Environment Variable Issues:
    • Check all required variables are set
    • Verify no typos in variable names
    • Ensure values don’t have extra spaces

Debug Mode

For debugging in production, temporarily set:

🎯 Production Best Practices

Security

Performance

Monitoring

πŸ”„ Updates and Maintenance

Regular Tasks

Deployment Process

  1. Test changes locally
  2. Push to feature branch
  3. Test on Vercel preview deployment
  4. Merge to main branch for production

πŸ†˜ Need Help?


πŸŽ‰ Congratulations! Your Poll Application is now running in production on Vercel!