Vercel — Frontend Platform
Deploy any frontend framework in seconds — automatic CI/CD, preview deployments, edge functions, and custom domains
Skills taught: deployment.vercel, deployment.preview-urls, deployment.edge-functions, deployment.vercel-config, deployment.vercel-env
Vercel — the frontend cloud
Vercel built its reputation deploying Next.js (it created Next.js), but it deploys any frontend framework: React, Vue, Svelte, Astro, Nuxt, Remix, and more. Connect your GitHub repo, and every push automatically builds and deploys. Every PR gets a unique preview URL. Custom domains get free HTTPS. Globally distributed CDN serves files from the nearest edge to your users. For most frontend apps, Vercel is the easiest path from code to production.
Deploying to Vercel
# Install Vercel CLI
npm install -g vercel
# Login
vercel login
# Deploy current directory
vercel
# Prompts:
# Set up and deploy? Y
# Which scope? (your account)
# Link to existing project? No
# Project name? my-react-app
# Directory? ./
# Override settings? No
# → Deploys to: https://my-react-app-abc123.vercel.app
# Deploy to production
vercel --prod
# → Deploys to: https://my-react-app.vercel.app (and your custom domain)
# Or via GitHub integration (no CLI needed):
# 1. vercel.com → New Project → Import from GitHub
# 2. Select repository → Deploy
# 3. Vercel auto-detects framework (React/Vite → npm run build → dist/)
# 4. From now on, every push to main = production deploy
# Every push to other branches = preview deploy
vercel.json — configuration
{
"framework": "vite",
"buildCommand": "npm run build",
"outputDirectory": "dist",
"installCommand": "npm ci",
"headers": [
{
"source": "/static/(.*)",
"headers": [
{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }
]
},
{
"source": "/(.*)",
"headers": [
{ "key": "X-Frame-Options", "value": "DENY" },
{ "key": "X-Content-Type-Options", "value": "nosniff" }
]
}
],
"redirects": [
{
"source": "/old-path",
"destination": "/new-path",
"permanent": true
}
],
"rewrites": [
{
"source": "/api/(.*)",
"destination": "https://api.myapp.com/$1"
},
{
"source": "/(.*)",
"destination": "/index.html"
}
]
}
Vercel Edge Functions
// Place in /api/ directory → automatically deployed as a serverless function
// Vercel supports Node.js serverless AND Edge runtime
// Edge function (runs at Vercel's global edge, ~0ms cold start):
export const config = { runtime: 'edge' };
export default function handler(req: Request) {
const url = new URL(req.url);
const name = url.searchParams.get('name') ?? 'World';
return new Response(
JSON.stringify({ message: `Hello, ${name}!`, region: process.env.VERCEL_REGION }),
{ headers: { 'Content-Type': 'application/json' } }
);
}
// Node.js serverless function (for heavier tasks with npm packages):
// api/users.ts
import type { VercelRequest, VercelResponse } from '@vercel/node';
export default async function handler(req: VercelRequest, res: VercelResponse) {
if (req.method === 'GET') {
const users = await db.query('SELECT id, name FROM users LIMIT 100');
res.json(users);
}
}
// Deployed at: https://myapp.vercel.app/api/users
// Works for simple APIs; for complex backends use Railway/Fly.io
Environment variables
# Via CLI:
vercel env add DATABASE_URL production
# → Prompts for value, encrypts and stores it
# Via CLI — add to all environments:
vercel env add NEXT_PUBLIC_API_URL production preview development
# List environment variables:
vercel env ls
# Pull env vars to local .env.local:
vercel env pull .env.local
# In your code:
# Server-side (not exposed to browser):
# process.env.DATABASE_URL
# Client-side (MUST prefix with NEXT_PUBLIC_ or VITE_ to be included in bundle):
# process.env.NEXT_PUBLIC_API_URL (Next.js)
# import.meta.env.VITE_API_URL (Vite)
# Per-environment variables:
# Production: STRIPE_SECRET_KEY = sk_live_...
# Preview: STRIPE_SECRET_KEY = sk_test_...
# Development: STRIPE_SECRET_KEY = sk_test_...
Tip: Vercel's preview deployments are better than you think. Each preview URL is fully functional with production-like config (using your 'Preview' environment variables). You can share it with your designer, PM, or client — no need for them to set up anything. The URL stays alive for 90 days. Comment directly on the preview from the Vercel toolbar. This workflow has replaced 'staging environments' for many teams.
Frequently Asked Questions
Is Vercel free?
The Hobby plan (personal projects) is free: unlimited deployments, 100GB bandwidth/month, serverless functions, preview deployments, and custom domains. The Pro plan ($20/month) adds team collaboration, more bandwidth, longer function duration, and password protection for previews. For most side projects and startups, Hobby is sufficient.