Agent skill · practicalswan
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 edge\", \"rewrite requests\", or editing files in netlify/edge-functions.
What it needs
About 9k tokens when loaded.
What this skill does
Netlify Edge Functions Reach for this (modern): default-export handler + inline config export with a narrowly-scoped path. Import types from @netlify/edge-functions. Avoid: import maps in deno.json (unsupported — use a separate file via denoimportmap). Do not hand-write a function your framework's adapter already generates (Next.js, Astro, Remix, SvelteKit, Nuxt, etc.) — check the framework adapter/reference first; duplicating adapter middleware causes conflicts. File location Default directory: YOURBASEDIRECTORY/netlify/edge-functions. Custom directory: edgefunctions key under [build] in netlify.toml. Keep it outside the publish directory so source files aren't deployed. .js/.ts/.jsx/.tsx all supported. If a .ts and .js file share a name, the .ts is ignored and the .js deploys. ⚠️ A function without a route silently never runs Edge functions are not auto-assigned a URL. No config export and no netlify.toml declaration = deploys clean, no build error, no warning, never executes. If "my edge function does nothing," check the route first. Request handling patterns Handler receives (request: Request, context: Context). Return one of: Response — respond directly (ends the chain; declared redirects for the path do not run) URL — rewrite to a same-site URL with 200 status (address bar unchanged) undefined / empty return; — bypass this function, continue the chain Netlify adds no headers to edge requests — use context for client info. Redirect Rewrite (same-site only) To reach another site or external content, use fetch() — rewrite via URL is same-site only. Middleware transform context.next() runs the rest of the chain and returns the origin Response. Only call it if you need the response body (it costs latency otherwise). To transform a different path, use fetch() — but this starts a new request chain and re-runs any edge functions matching that path. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills practicalswan/netlify-edge-functions