Back to Skills

netlify-edge-functions

Write, configure, and deploy Netlify Edge Functions (Deno runtime at the network edge) in TypeScript/JavaScript. Use when adding request/response manipulation at the edge — auth middleware, geolocation redirects, A/B testing and personalization, content localization, redirects/rewrites, SSR at the edge, or transforming responses — or when configuring path routing, response caching, or edge error handling. Triggers on tasks like "add auth middleware", "geo-based redirect", "A/B testing at the edg

34stars7forksUpdated 8/13/2026

Security Assessment

Safe(96/100)
Security Score96/100

About netlify-edge-functions

netlify-edge-functions is a developer guidance skill for writing, configuring, and deploying Netlify Edge Functions, which run on Netlify's globally distributed edge network using the Deno runtime. It solves the problem of getting edge compute right — request/response manipulation, auth middleware, geolocation redirects, A/B testing, localization, redirects/rewrites, edge SSR, and response transformation — by documenting the runtime's non-obvious behaviors that commonly trip developers up.

The skill covers the function syntax and the Config object (path, excludedPath, method, onError, cache), and emphasizes practical pitfalls: scoping `path` narrowly so the function does not intercept every static asset, opting into caching with `cache: "manual"` before cache headers take effect, and binding functions to a path via inline config or a netlify.toml `[[edge_functions]]` entry (an unbound function deploys but silently never runs). It explains chaining order when multiple functions match a path, that edge functions execute before redirect/rewrite rules and match the original URL, and the middleware pattern using context.next(). It also documents geolocation and IP access via context.geo/context.ip, cookie handling through context.cookies, environment variables via Netlify.env, and module support for Node builtins, npm packages, and Deno URL imports.

It targets frontend and full-stack developers deploying to Netlify who need low-latency edge logic. Typical use cases include adding authentication gates, geo-based routing, personalization, and response header manipulation. The content is educational reference material about a hosting platform's API and contains no destructive or credential-exfiltrating behavior.

FAQ

Where do edge function files live and how are they bound?

Place files in netlify/edge-functions/ using .ts/.js/.tsx/.jsx extensions. Each function must be bound to a path either with an inline `export const config = { path: ... }` or a `[[edge_functions]]` entry in netlify.toml; an unbound function deploys but silently never runs.

Why isn't my Cache-Control header working at the edge?

Cache headers on an edge response have no effect unless the function also sets config.cache = "manual". It is both or neither — without the flag the response is never cached regardless of headers.

In what order do multiple edge functions on the same path run?

Functions declared in netlify.toml run first in file order, then inline-config functions run in alphabetical order by filename, and caching functions (cache: "manual") always run after non-caching ones. Use netlify.toml ordering for deterministic sequencing like an auth gate before a rewrite.

How do edge functions interact with redirects?

Edge functions run before redirect/rewrite rules and match against the original requested URL. If a function returns a Response the chain stops and redirect rules for that path never run; return context.next() or undefined to let redirects still apply.

How do I access geo, cookies, and environment variables?

Use context.geo (city, country, subdivision, timezone) and context.ip for geolocation, context.cookies.get/set/delete for cookies, and Netlify.env.get for environment variables rather than process.env or Deno.env. Local geo can be mocked with netlify dev --geo=mock.

Install netlify-edge-functions

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill