Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
netlify avatar

Netlify Edge Functions

  • 1.5k installs
  • 31 repo stars
  • Updated August 4, 2026
  • netlify/context-and-tools

netlify-edge-functions is a Netlify skill that guides writing Deno-based Netlify Edge Functions for low-latency middleware, geolocation logic, authentication checks, and request/response transforms on Netlify's global ed

About

netlify-edge-functions from netlify/context-and-tools teaches how to author Netlify Edge Functions that run on Netlify's globally distributed edge network using the Deno runtime. The skill covers the @netlify/edge-functions Config and Context types, the context.next() middleware pattern, geolocation-aware routing, authentication guards, A/B tests, and when to choose edge compute versus serverless functions. Developers use it while adding low-latency redirects, header rewrites, or geo rules without provisioning separate edge infrastructure. Reach for netlify-edge-functions when a JAMstack or SSR app on Netlify needs request filtering closer to users than a single-region lambda.

  • Deno runtime with full TypeScript support for edge functions
  • Middleware pattern using context.next() for request/response chaining
  • Built-in geolocation, A/B testing, and authentication helpers
  • Configurable path, method, cache, and onError behaviors
  • Files placed in netlify/edge-functions/ with .ts/.js extensions

Netlify Edge Functions by the numbers

  • 1,460 all-time installs (skills.sh)
  • +131 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #329 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/netlify/context-and-tools --skill netlify-edge-functions

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.5k
repo stars31
Last updatedAugust 4, 2026
Repositorynetlify/context-and-tools

How do you write Netlify Edge Functions middleware in Deno?

Quickly implement low-latency middleware, geolocation rules, authentication guards, and request/response transforms that run on Netlify's edge network.

Who is it for?

Full-stack developers shipping on Netlify who need edge middleware for auth, geolocation, A/B tests, or header and body transforms.

Skip if: AWS Lambda@Edge projects, long-running compute jobs, or backends not deployed on Netlify's edge network.

When should I use this skill?

The user builds Netlify Edge Functions, edge middleware, geolocation routing, or auth checks with @netlify/edge-functions.

What you get

TypeScript edge function files with Config exports, context.next() middleware chains, and deployed low-latency request handlers on Netlify.

  • Netlify Edge Function TypeScript modules
  • Middleware chain using context.next()
  • Edge deployment configuration guidance

Files

SKILL.mdMarkdownGitHub ↗

Netlify Edge Functions

Edge functions run on Netlify's globally distributed edge network (Deno runtime), providing low-latency responses close to users.

Syntax

import type { Config, Context } from "@netlify/edge-functions";

export default async (req: Request, context: Context) => {
  return new Response("Hello from the edge!");
};

export const config: Config = {
  path: "/hello",
};

Place files in netlify/edge-functions/. Uses .ts, .js, .tsx, or .jsx extensions.

Config Object

export const config: Config = {
  path: "/api/*",                    // URLPattern path(s)
  excludedPath: "/api/public/*",     // Exclusions
  method: ["GET", "POST"],           // HTTP methods
  onError: "bypass",                 // "fail" (default), "bypass", or "/error-page"
  cache: "manual",                   // Enable response caching
};

Middleware Pattern

Use context.next() to invoke the next handler in the chain and optionally modify the response:

export default async (req: Request, context: Context) => {
  // Before: modify request or short-circuit
  if (!isAuthenticated(req)) {
    return new Response("Unauthorized", { status: 401 });
  }

  // Continue to origin/next function
  const response = await context.next();

  // After: modify response
  response.headers.set("x-custom-header", "value");
  return response;
};

Return undefined to pass through without modification:

export default async (req: Request, context: Context) => {
  if (!shouldHandle(req)) return; // continues to next handler
  return new Response("Handled");
};

Geolocation and IP

export default async (req: Request, context: Context) => {
  const { city, country, subdivision, timezone } = context.geo;
  const ip = context.ip;

  if (country?.code === "DE") {
    return Response.redirect(new URL("/de", req.url));
  }
};

Local dev with mocked geo: netlify dev --geo=mock --country=US

Environment Variables

Use Netlify.env (not process.env or Deno.env):

const secret = Netlify.env.get("API_SECRET");

Module Support

  • Node.js builtins: import { randomBytes } from "node:crypto";
  • npm packages: Install via npm and import by name
  • Deno modules: URL imports (e.g., import X from "https://esm.sh/package")

For URL imports, use an import map:

// import_map.json
{ "imports": { "html-rewriter": "https://ghuc.cc/worker-tools/html-rewriter/index.ts" } }
# netlify.toml
[functions]
  deno_import_map = "./import_map.json"

When to Use Edge vs Serverless

Use Edge Functions forUse Serverless Functions for
Low-latency responsesLong-running operations (up to 15 min)
Request/response manipulationComplex Node.js dependencies
Geolocation-based logicDatabase-heavy operations
Auth checks and redirectsBackground/scheduled tasks
A/B testing, personalizationTasks needing > 512 MB memory

Limits

ResourceLimit
CPU time50 ms per request
Memory512 MB per deployed set
Response header timeout40 seconds
Code size20 MB compressed

Related skills

How it compares

Use netlify-edge-functions for Netlify-specific Deno edge middleware; use generic serverless skills when compute runs only in regional functions outside Netlify.

FAQ

What runtime do Netlify Edge Functions use?

Netlify Edge Functions run on Netlify's globally distributed edge network using the Deno runtime. The netlify-edge-functions skill imports Config and Context from @netlify/edge-functions and uses context.next() for middleware chains.

When should developers choose edge functions over Netlify serverless?

Developers should choose Netlify Edge Functions for low-latency middleware such as geolocation routing, authentication guards, A/B tests, and header or body transforms close to users. The netlify-edge-functions skill contrasts these cases with heavier serverless workloads.

Backend & APIsintegrationsbackend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.