Netlify Edge Functions
Netlify Edge Functions are serverless functions built on the Deno runtime that execute at edge locations across Netlify's global network, allowing developers to modify requests and responses — such as personalization, redirects, and A/B…
Definition
Netlify Edge Functions are serverless functions built on the Deno runtime that execute at edge locations across Netlify's global network, allowing developers to modify requests and responses — such as personalization, redirects, and A/B testing — with low latency close to the visitor.
Overview
Netlify Edge Functions let developers run TypeScript or JavaScript code that intercepts and modifies HTTP requests and responses before they reach a static site or serverless function, executing at edge locations distributed globally rather than a single origin region. Unlike Netlify's standard Functions (which run on AWS Lambda in a specific region), Edge Functions are powered by Deno, a secure-by-default JavaScript/TypeScript runtime, giving them fast cold starts and access to modern Web APIs without a Node.js dependency footprint. Edge Functions are declared either via a configuration file (`netlify.toml`) mapping URL paths to function files, or using in-source configuration that exports a `config` object specifying a `path` pattern directly in the function file. Each function receives the incoming `Request` and a `Context` object exposing metadata like the visitor's geolocation, IP, and cookies, and can either transform the response, short-circuit with a custom response (e.g., a redirect or an A/B test variant), or pass the request through to the origin using `context.next()`. Because Edge Functions run before Netlify's CDN cache and origin, they are particularly well suited to request-path logic that needs to run on every visit — geolocation-based content, authentication gating, feature flagging, and dynamic redirects — without needing a full server round-trip. They complement rather than replace Netlify's standard serverless Functions, which remain the better choice for longer-running, more compute- or dependency-heavy backend logic. As a Deno-based runtime, Edge Functions support native TypeScript, npm compatibility via Deno's npm specifier support, and a security model that requires explicit permissions for filesystem, network, and environment access, aligning with the broader move among edge platforms toward lightweight, standards-based JavaScript runtimes.
Key Features
- Runs on Deno, giving fast cold starts and native TypeScript support
- Executes at edge locations globally, ahead of CDN cache and origin
- Configured via `netlify.toml` or in-source `config` exports with path patterns
- Provides request Context with geolocation, IP, and cookie data
- Can transform, redirect, or short-circuit responses before they reach origin
- Complements (not replaces) Netlify's standard AWS Lambda-based Functions
- Deno's npm compatibility allows many existing npm packages to run
- Well suited to personalization, feature flagging, and geo-based logic
Use Cases
Alternatives
Frequently Asked Questions
From the Blog
Python Functions Explained for Beginners
Functions are named, reusable blocks of code — learn to define them, pass arguments, and return values.
Read More ProgrammingJavaScript ES6+ Features Every Developer Should Know
ES6 and beyond transformed JavaScript from a quirky scripting language into a powerful modern programming language. This guide covers the most important features: arrow functions, destructuring, template literals, async/await, modules, and more.
Read More ProgrammingObject-Oriented Programming in Python: A Practical Guide
OOP is how Python codebases stay organised as they grow. This guide explains classes, inheritance, encapsulation, and polymorphism with real examples — and tells you honestly when to use OOP and when plain functions are the better choice.
Read More ProgrammingPython Decorators: A Practical Guide for Beginners
Decorators are one of Python's most powerful features — they let you wrap functions with reusable logic without modifying the original. This guide explains how they work from first principles, builds several practical decorators (timing, caching, authentication), and covers class-based decorators and decorator factories.
Read More