Overview
Vercel is optimized for modern web frameworks and provides excellent developer experience with instant deployments and built-in CI/CD.Features
Instant Deployments
Deploy in seconds with global CDN
Automatic HTTPS
Free SSL certificates
Git Integration
Auto-deploy from GitHub, GitLab, or Bitbucket
Preview Deployments
Unique URL for every PR
Analytics
Web Analytics and Speed Insights
Edge Network
Global CDN with edge caching
Option 1: Deploy from Git Repository
Import Project
- Go to Vercel
- Click “Add New…” → “Project”
- Import your Git repository:
- GitHub: Connect and select repo
- GitLab: Connect and select repo
- Bitbucket: Connect and select repo
Configure Project
Vercel auto-detects Vite settings:
- Framework Preset: Vite
- Build Command:
npm run build - Output Directory:
dist - Install Command:
npm install
Add Environment Variables
Before deploying, add Supabase credentials:
- Click Environment Variables
- Add both variables:
- Select all environments: Production, Preview, Development
Deploy
Click “Deploy”. Vercel will:
- Clone your repository
- Install dependencies
- Build the project
- Deploy to global CDN
Option 2: Deploy with Vercel CLI
Deploy Project
In your project directory:Follow the prompts:
- Set up and deploy: Yes
- Which scope: Select your account
- Link to existing project: No (first time)
- Project name: Accept default or customize
- Directory:
./(current directory) - Auto-detected settings: Yes
Add Environment Variables
- Enter the value
- Select environments: Production, Preview, Development
SPA Routing Configuration
For Vue Router to work correctly, createvercel.json in your project root:
vercel.json:2
Custom Domain Setup
Add Domain
In Vercel dashboard:
- Select your project
- Go to Settings → Domains
- Click “Add” and enter your domain
Configure DNS
Vercel provides DNS configuration:Option A: Use Vercel nameserversOption B: Add CNAME record
Environment Variables
Adding Variables via Dashboard
Add Variable
For each variable:
- Enter Key (e.g.,
VITE_SUPABASE_URL) - Enter Value
- Select Environments:
- ✅ Production
- ✅ Preview
- ✅ Development
- Click Save
Required Variables
Continuous Deployment
Vercel automatically deploys:- Production: Pushes to
mainbranch - Preview: Pull requests and other branches
Preview Deployments
Every PR and branch gets a unique URL:- Preview URL
- Build status
- Deployment logs
Build Configuration
Build Settings
Vercel auto-detects frompackage.json:
Custom Build Command
Override invercel.json:
Troubleshooting
Build Fails
Problem: Build exits with error Solutions:- Check build logs in Vercel dashboard
- Test build locally:
npm run build - Verify Node version compatibility:
- Check all dependencies are in
package.json
404 on Page Refresh
Problem: Refreshing a route returns 404 Solution: Ensurevercel.json exists with rewrite rules:
Environment Variables Not Working
Problem: Variables areundefined in production
Solutions:
- Verify variables are added in Vercel dashboard
- Ensure names start with
VITE_prefix - Redeploy after adding variables
- Check build logs for warnings
Supabase Connection Fails
Problem: “Failed to fetch” errors in production Solutions:- Add Vercel domain to Supabase Authentication → URL Configuration:
- Add to Redirect URLs:
- Verify environment variables are correct
Performance Optimization
Automatic Optimizations
Vercel provides:- Image optimization (using
<Image>component) - Asset compression (Brotli/gzip)
- Edge caching (static assets)
- Global CDN (edge network)
Build Cache
Vercel caches dependencies between builds:node_modules/.next/cache(if using Next.js)
Analytics
Web Analytics
Enable analytics:- Go to Analytics tab
- Click “Enable Analytics”
- View metrics:
- Page views
- Top pages
- Top referrers
- Devices and browsers
Speed Insights
Monitor real-world performance:- Go to Speed Insights tab
- View Core Web Vitals:
- First Contentful Paint (FCP)
- Largest Contentful Paint (LCP)
- Cumulative Layout Shift (CLS)
- First Input Delay (FID)
Next Steps
Environment Variables
Configure required variables
Supabase Setup
Complete backend configuration
