Vercel deployment, serverless functions, and edge configuration. Use when user mentions "vercel", "vercel deploy", "vercel CLI", "serverless functions", "edge functions", "vercel.json", "preview deployments", "vercel domains", "vercel env", "vercel cron", "vercel KV", "vercel postgres", "vercel blob", "ISR", or deploying web applications to Vercel.
Vercel
CLI Essentials
npm i -g vercel # install CLI
vercel login # authenticate (browser flow)
vercel link# link current directory to a Vercel project
vercel # deploy to preview
vercel --prod # deploy to production
vercel dev # run local dev server (mirrors Vercel environment)
vercel dev --listen 4000 # custom port# Environment variables
vercel envls# list all env vars
vercel env add SECRET_KEY # add interactively (prompts for value and scope)
vercel env add DATABASE_URL production < .env.production # pipe value for specific scope
vercel env pull .env.local # pull remote env vars to local file
vercel envrm SECRET_KEY production # remove from specific environment
vercel domains
vercel domains add example.com
vercel domains inspect example.com
vercel logs https://my-deploy-url.vercel.app
vercel inspect <deployment-url>
vercel
vercel rollback <deployment-url>
# Domains
ls
# list domains
# add domain
# DNS and certificate status
# Logs and inspection
# stream deployment logs
# deployment details (functions, routes, size)
ls
# list recent deployments
# revert production to a previous deployment
Project Configuration (vercel.json)
{// Rewrites (URL stays the same, content served from destination)"rewrites":[{"source":"/api/:path*","destination":"/api/:path*"},{"source":"/(.*)","destination":"/index.html"}// SPA fallback],// Redirects"redirects":[{"source":"/old-page","destination":"/new-page","permanent":true},{"source":"/blog/:slug","destination":"https://blog.example.com/:slug","statusCode":308}],// Custom headers"headers":[{"source":"/api/(.*)","headers":[{"key":"Access-Control-Allow-Origin","value":"*"},{"key":"Cache-Control","value":"s-maxage=86400"}]}],// Function configuration"functions":{"api/heavy-task.ts":{"memory":1024,// MB (128–3008)"maxDuration":60// seconds (Hobby: 60, Pro: 300, Enterprise: 900)},"api/edge-fn.ts":{"runtime":"edge"}},// Cron jobs"crons":[{"path":"/api/cron/daily-cleanup","schedule":"0 0 * * *"// standard cron syntax (UTC)},{"path":"/api/cron/hourly-sync","schedule":"0 * * * *"}],// Build and output"buildCommand":"npm run build","outputDirectory":"dist","installCommand":"npm ci","framework":"nextjs",// auto-detected; override if needed"regions":["iad1","sfo1"],// deploy functions to specific regions// Clean URLs: /about instead of /about.html"cleanUrls":true,"trailingSlash":false}
Framework Detection and Build Settings
Vercel auto-detects frameworks: Next.js, Nuxt, SvelteKit, Remix, Astro, Vite, CRA, Gatsby, Angular, Hugo, etc. Override in project settings or vercel.json when auto-detection fails.
// Override build settings in vercel.json{"framework":"vite","buildCommand":"vite build","outputDirectory":"dist","installCommand":"pnpm install","devCommand":"vite dev --port $PORT"}
Node.js version: set in package.json engines field or project settings. Supports 18.x (default) and 20.x.
Environment Variables
Three scopes: Development, Preview, Production.
Production: available only on production deployments
Preview: available on preview deployments (each PR gets one)
Development: available when running vercel dev
System env vars are auto-injected: VERCEL_ENV, VERCEL_URL, VERCEL_BRANCH_URL, VERCEL_GIT_COMMIT_SHA, VERCEL_GIT_COMMIT_REF.
Sensitive values: mark as "Sensitive" in dashboard (encrypted, never shown in logs). For local dev, use vercel env pull to sync to .env.local.
Serverless Functions
Place files in the /api directory. Each file becomes an endpoint matching its path.
// vercel.json at repo root{"projects":[{"name":"web","rootDirectory":"apps/web"},{"name":"docs","rootDirectory":"apps/docs"}]}
In project settings (dashboard or CLI):
Root Directory: apps/web — Vercel only builds this subdirectory
Include/Ignore Build Step: skip builds when no relevant files changed
# Ignore build step — custom script in project settings# Only rebuild if files in this project or shared packages changed
git diff --quiet HEAD^ HEAD -- apps/web/ packages/shared/ || exit 0
Works with Turborepo, Nx, pnpm workspaces. Vercel auto-detects Turborepo and uses turbo run build --filter=<project>.
Speed Insights tracks Core Web Vitals (LCP, FID, CLS, TTFB, INP) with real user data. Analytics provides pageviews, unique visitors, and referrers — no cookies, GDPR-compliant.