Vercel

Vercel is a cloud platform focused on frontend deployment — especially Next.js, which it maintains — with a developer experience built around Git: every push deploys, every pull request gets a live preview URL. Under the hood it gives you static hosting on a global CDN, serverless functions, and edge functions, with image optimization and caching baked in.

It shines when you lean into its model (static generation + CDN, preview deployments as part of your workflow) and frustrates when you fight it (long-running jobs, persistent connections). Knowing which runtime your code lands on is the key to using it well.

TL;DR

Quick Example

A push to a branch is a deploy — no pipeline to write:

What Vercel Provides

It's strongest when you use static generation + CDN, incremental/static rendering, and previews as a core part of development.

Rendering Modes

The Next.js mental model maps directly to how Vercel serves each route:

⚠️ If your app has authenticated, user-specific pages, be explicit about what can be cached — accidentally caching personalized responses leaks one user's data to another.

Environment Variables

Vercel scopes variables to three environments — development, preview, and production:

⚠️ Preview is the common footgun for leaking prod data — treat it as a real environment with its own least-privilege keys, not a copy of production. See Secrets Management.

Caching & Performance

Common Gotchas

When to Use Vercel (and When Not To)

Great fit: frontend-heavy apps, docs and marketing sites, Next.js apps where preview deployments matter, teams optimizing iteration speed.

Consider alternatives: long-running background jobs or heavy compute, workloads needing custom networking, persistent connections, or non-HTTP protocols — a dedicated API service or container platform fits those better.

Common Mistakes

Writing to the local filesystem

Opening a new DB connection per request

FAQ

Do I have to use Next.js with Vercel?

No — Vercel hosts any static site and many frameworks (Astro, SvelteKit, Vite, Nuxt). But its tightest integration and most of its advanced features (ISR, image optimization, middleware) are designed around Next.js, which Vercel develops. Non-Next apps work well for static + serverless use cases.

What's the difference between Edge and Serverless functions?

Serverless functions run in a full Node.js runtime in a specific region — more capable, but with cold starts and higher latency for distant users. Edge functions run a lightweight runtime at many global locations close to users — very low latency, but with a restricted API surface and limits on execution time and package size. Use edge for fast, simple logic; serverless for fuller workloads.

How do I avoid leaking production data in previews?

Give the preview environment its own credentials with least privilege — ideally pointing at a separate database or a safe staging dataset. Never reuse production secrets in preview. Treat preview URLs as semi-public and gate sensitive previews behind authentication.

Why is my serverless function exhausting database connections?

Each concurrent invocation can open its own connection, and serverless scales to many concurrent instances. Use a connection pooler/proxy (RDS Proxy, PgBouncer, Prisma Accelerate) or a serverless-native driver that pools over HTTP, and initialize the client at module scope so warm instances reuse it.

Related Topics

References