Skip to main content
This guide covers deploying your Vite + React application to various hosting platforms. The application builds to static files that can be served from any CDN or static hosting provider.

Build Process

The application uses Vite as its build tool. The build process is configured in vite.config.ts and produces optimized static assets.

Build Commands

npm run build
The production build command (npm run build) creates an optimized bundle in the dist/ directory with:
  • Minified JavaScript and CSS
  • Code splitting for optimal loading
  • Hashed filenames for cache busting
  • Optimized assets

Environment Variables

Before deploying, you need to configure the following environment variables:
VITE_SUPABASE_URL
string
required
Your Supabase project URL (e.g., https://xxxxx.supabase.co)
VITE_SUPABASE_ANON_KEY
string
required
Your Supabase anonymous/public API key
Never commit environment variables to version control. Use your platform’s environment variable management system.

Deployment Platforms

Vercel provides seamless deployment for Vite applications with automatic builds and previews.
1

Install Vercel CLI

npm install -g vercel
2

Login to Vercel

vercel login
3

Configure Project

Create a vercel.json file in your project root:
vercel.json
{
  "buildCommand": "npm run build",
  "outputDirectory": "dist",
  "devCommand": "npm run dev",
  "installCommand": "npm install"
}
4

Set Environment Variables

Add your environment variables in the Vercel dashboard or via CLI:
vercel env add VITE_SUPABASE_URL
vercel env add VITE_SUPABASE_ANON_KEY
5

Deploy

Deploy to production:
vercel --prod

Build Settings

If deploying via the Vercel dashboard:
  • Framework Preset: Vite
  • Build Command: npm run build
  • Output Directory: dist
  • Install Command: npm install
  • Node Version: 18.x or higher

Domain Configuration

After deployment, configure your custom domain:
1

Add Domain to Platform

Add your custom domain in your hosting platform’s dashboard (Vercel, Netlify, etc.).
2

Update DNS Records

Add the required DNS records provided by your platform:
  • A Record or CNAME Record pointing to your platform
  • AAAA Record for IPv6 (if provided)
3

Enable HTTPS

Most platforms automatically provision SSL certificates via Let’s Encrypt. Enable HTTPS redirect in your platform settings.
4

Update Supabase Redirect URLs

In your Supabase dashboard, add your production domain to the allowed redirect URLs:
  • Go to Authentication > URL Configuration
  • Add https://your-domain.com to Site URL
  • Add https://your-domain.com/** to Redirect URLs

Post-Deployment Checklist

Environment variables are configured correctly
Supabase connection is working
Authentication flows work properly
All routes are accessible (no 404 errors)
SSL/HTTPS is enabled
Custom domain is configured
Error monitoring is set up (optional)
Performance monitoring is configured (optional)

Continuous Deployment

Enable automatic deployments by connecting your Git repository:
  1. Connect Repository: Link your GitHub, GitLab, or Bitbucket repository to your hosting platform
  2. Configure Branch: Set your production branch (usually main or master)
  3. Enable Auto-Deploy: Every push to the production branch will trigger a new deployment
  4. Preview Deployments: Most platforms create preview deployments for pull requests
Preview deployments are useful for testing changes before merging to production.

Troubleshooting

Build Fails

  • Check Node.js version (18.x or higher recommended)
  • Verify all dependencies are installed: npm install
  • Check for TypeScript errors: npm run lint
  • Review build logs for specific error messages

Blank Page After Deployment

  • Verify environment variables are set correctly
  • Check browser console for errors
  • Ensure base path is configured correctly in vite.config.ts
  • Verify Supabase URL and API key are valid

404 on Page Refresh

  • Configure URL rewriting rules (see platform-specific instructions above)
  • Ensure all routes redirect to index.html for client-side routing

Supabase Connection Error

  • Verify VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY are set
  • Check Supabase project status
  • Ensure API keys haven’t been regenerated
  • Verify domain is in Supabase allowed URLs

Next Steps

Supabase Setup

Configure your Supabase backend for production

Analytics Dashboard

Monitor your platform with real-time analytics

Build docs developers (and LLMs) love