A traditional serverless function runs in one region; every request, wherever it comes from, travels there and back. An edge function runs in dozens of locations simultaneously, executing the code physically close to wherever the request originated.

// Runs at the edge, close to the user, not in one central region
export default function handler(request) {
  const country = request.geo?.country || 'unknown';
  return new Response(`Hello from ${country}`);
}

Where the latency actually matters

Personalisation logic, A/B test assignment, and geo-based redirects are the clearest wins - decisions that need to happen before the page renders, where every millisecond of round-trip latency is directly visible to the user.

Real constraints, not a free upgrade

Edge runtimes are intentionally limited - no full Node.js API surface, tighter execution time limits. It's the right tool for a specific class of problem, not a wholesale replacement for a traditional backend.

Moving compute closer to the request, not just the content

CDNs solved "serve static assets from somewhere physically close to the visitor" years ago. Edge functions extend the same idea to actual logic - auth checks, A/B test assignment, geolocation-based redirects - running in a data center near the visitor instead of a single origin server that might be a continent away.

export default function middleware(request) {
  const country = request.geo?.country || 'US';
  if (country === 'DE') return NextResponse.redirect('/de');
}

What still belongs on the origin

Edge runtimes trade full Node.js compatibility for speed and global distribution - no arbitrary native modules, tighter memory and execution-time limits. Anything doing heavy computation, talking to a traditional relational database with a persistent connection, or needing the full Node API still belongs on a conventional server; edge functions are best treated as a fast, globally-distributed front door, not a replacement for the whole backend.