Edge Function
A server-side function deployed to a globally distributed edge network, running close to the user with lower latency and different constraints than traditional serverless.
What is an edge function?
Edge functions run on a worldwide network of small, lightweight servers rather than in a single data center. A request from Tokyo hits a Tokyo edge; a request from Berlin hits a Berlin edge. Response times are typically under 50ms versus 200ms+ for traditional serverless in a single region.
Vendors: Vercel Edge Functions, Cloudflare Workers, Supabase Edge Functions, Netlify Edge Functions.
What they are good for
- Personalization and A/B testing on cold visits
- Auth checks and redirects before hitting origin
- Lightweight APIs where startup time dominates
- Image transforms and asset generation (OG images)
What they are bad for
- Long-running code (typical limit 30s, often less)
- Heavy dependencies (bundle size limits, typically 1MB unzipped)
- Node-specific APIs (most edge runtimes are V8-only)
- Direct database connections (use a pool or HTTP-based driver)
Common AI-built app mistake
Generating a route as an edge function by default, then importing a Node-only package (Prisma, pg, sharp). The deploy silently breaks at runtime with an obscure error. Match the runtime to the code.