Edge function
Server code that runs in whatever datacenter is closest to the visitor, instead of in one machine far away.
See it
What it is
An edge function is a small piece of server code that the platform runs in its own edge locations instead of in one datacenter you picked. A request from Lagos is handled wherever the provider routes it, which is usually far closer than your origin but is not guaranteed to be the visitor's own city, and not every provider runs your code in every location it owns. Startup is measured in single-digit milliseconds because the sandbox is light: V8 isolates on Cloudflare Workers, Vercel Edge Functions, and Deno Deploy, WebAssembly on Fastly Compute.
Reach for it when the work is short, request-shaped, and latency-sensitive: A/B bucketing, geo redirects, auth checks on a cookie, header rewrites, personalizing a cached page, signing an image URL. Anything that decides something fast and gets out of the way.
Two gotchas. First, the runtime is a web-standards sandbox rather than full Node: no filesystem, no native modules, a tight CPU budget, and only whatever slice of Node compatibility your particular provider offers, so plenty of npm will not run and the supported list differs between platforms. Second, running near the user does not help if your database is still in Virginia. Three sequential queries from an edge function can be slower than one regional function sitting next to the data.
Ask AI for it
Inspect this repository's deployment config and target exactly one detected edge platform (Cloudflare Workers, Vercel, Deno Deploy, Fastly Compute). Implement the handler in that platform's native module shape rather than a generic one, use only the APIs that platform documents as supported, and read the visitor's location from its own documented geo metadata instead of assuming a header name. Make at most one outbound request, keep the work inside that platform's CPU limit, stream the response instead of buffering it, and include the deployment configuration file that platform needs. If no edge platform is configured here, say so and ask me which one to target before writing any code.