Deployments, Config & Functions
CLI & Preview Deployments
vercel login
vercel link # associate this directory with a Vercel project
vercel # deploy — creates a Preview URL
vercel --prod # deploy straight to production
vercel env add API_URL preview # scoped per environment —
vercel env add API_URL production # Preview can point at staging, Prod at live
# Every push to a non-production branch gets its OWN isolated,
# shareable Preview deployment — multiple features reviewable in
# parallel with zero risk of one clobbering another's testingvercel.json
{
"redirects": [
{ "source": "/old-blog/:path*", "destination": "/blog/:path*", "permanent": true }
],
"headers": [
{
"source": "/assets/(.*)",
"headers": [{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }]
}
]
}Serverless & Edge Functions
// api/hello.js — serverless Function, full Node.js runtime
export default function handler(req, res) {
res.status(200).json({ message: 'Hello from a region-based Function' });
}
// Edge Function — lightweight V8 isolate, runs at edge locations globally,
// near-instant cold starts, but a more constrained API surface (no full Node.js)
export const config = { runtime: 'edge' };
export default function handler(request) {
const country = request.geo?.country;
return new Response(`Hello from ${country}`);
}
// Heavy compute/DB work belongs in a serverless Function; latency-sensitive
// logic (geo redirects, A/B tests) fits an Edge Function better.Keep your own version of these notes — editable, searchable, and organised by your stack.
Start free