How it works
A CDN already keeps copies of files in hundreds of cities, known as the edge of the network. Edge functions put code there too: a request from Mumbai is handled in or near Mumbai, one from London in London. Most run in V8 isolates, lightweight sandboxes built on the JavaScript engine from Chrome, which start in milliseconds, so there is little of the cold-start delay that regular serverless functions have.
The trade-off is a slimmed-down runtime: web-standard APIs such as fetch rather than all of Node.js, tight CPU limits and small bundles. Speed also depends on where the data lives; an edge function that queries a database on another continent can end up slower than a regular function sitting next to that database. Cloudflare Workers, Deno Deploy, Netlify Edge Functions and Supabase Edge Functions are examples.
That lesson has shaped the platforms. Recent versions of Next.js no longer support the edge runtime for pages and routes and run them on Node.js in a chosen region instead, while edge code remains popular for redirects, sign-in checks and caching in front of an app.
Edge computing and edge functions pros and cons
Pros
- Low latency for visitors spread across the world
- Near-instant start-up, with little or no cold start
- Good for redirects, sign-in checks, A/B tests and personalisation
- Usually cheap per request, with generous free tiers
Cons
- Limited runtime: many Node.js packages will not run
- Slower, not faster, when the database sits in one distant region
- Tight CPU and memory limits per request
When to use Edge computing and edge functions
Pick it when
- Redirects, headers, geolocation and sign-in checks before a page loads
- APIs that read from a cache or from globally replicated data
- An audience spread across many countries
Skip it when
- Most work is heavy queries against a database in one region
- The code depends on Node.js-only libraries or native modules
Related terms
More in Hosting and cloud
The basics