100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Cloud

Netlify Edge Functions

IntermediateService12.1K learners

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

Geolocation-based content personalization and localization
A/B testing and feature flag evaluation at the edge
Authentication and access control before serving protected content
Dynamic redirects based on cookies, headers, or query parameters
Rewriting response headers for security or caching policy
Bot and traffic filtering at the network edge
Injecting personalized content into otherwise static pages

Alternatives

Vercel Edge Functions · VercelCloudflare Workers · CloudflareAWS Lambda@Edge · AWSSupabase Edge Functions · Supabase

Frequently Asked Questions

From the Blog