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…
от PracticalSwan★ 25 звёзд на GitHubОб этом скилле
Netlify Edge Functions
Use this form
// netlify/edge-functions/hello.ts
import type { Config, Context } from "@netlify/edge-functions";
export default async (request: Request, context: Context) => {
return new Response(`Hello from ${context.geo.country?.name ?? "somewhere"}`);
};
export const config: Config = { path: "/hello" };
- One file = one function: a default-export handler plus a named
configexport with the route. Alternatively, declare the route innetlify.toml. - The default export can also be a Fetchable module: an object with a
fetchmethod. Netlify callsfetchwith the same(request, context)arguments and uses its return value the same way; insidefetch,thisis the exported object. Use it to share one handler with other platforms that accept Fetchable modules.export default { async fetch(request: Request, context: Context) { return new Response("Hello"); }, }; export const config: Config = { path: "/hello" }; // still a named export RequestandResponseare global. ImportContextandConfigtypes from@netlify/edge-functions.- Read env vars with
Netlify.env.get().process.envworks only for Next.js middleware.
Avoid these:
- A file with no
config.pathorpatternand noedge_functionsentry. It deploys but never runs. - Import maps in
deno.json. They are unsupported. Use a separate file with[functions] deno_import_map. - Variables set in
netlify.toml. They are invisible to edge functions. Netlify.env.set()orNetlify.env.delete()as persistence. They affect only the current invocation.fetch()to the same site for the current path. Usecontext.next()instead.
⚠️ Footguns
- No route = silent no-op. Edge functions get no automatic URL.
path: "/*"runs on every request, including assets. Narrow it, or addexcludedPath.- Caching needs both parts:
cache: "manual"in config AND cache headers on the returnedResponse. With only one, nothing is cached. - Cached functions shadow static files. A cached function on
/*serves/cat.pnginstead of the file. - Returning a
Responseends the chain. Redirect rules for that path never run. - Same-site
fetch()andURLrewrites start a new request chain. Matching edge functions run again. Usecontext.next()to reach the static asset or serverless function at the same path. - The request body can be read once. After
await req.json(), passnew Request(req, { body })tocontext.next(). - Same-named
foo.tsandfoo.js: the TS file is ignored and the JS file deploys. - 50 ms CPU per request, including
waitUntilwork. - Not executed on sites with Split Testing enabled.
- Custom Headers and basic-auth headers do not apply to edge functions.
- Not supported on HIPAA-compliant hosting.
netlify.appis on the Public Suffix List. Cross-subdomain cookies need a custom domain.
Files
| What | Where |
|---|---|
| Functions | <base>/netlify/edge-functions/*.{js,ts,jsx,tsx} |
| Custom dir | [build] edge_functions = "my-dir" (relative to base dir; keep it outside the publish dir) |
| Name in toml | file name without extension (auth.ts → function = "auth") |
| Import map | any JSON file, referenced by [functions] deno_import_map = "./import_map.json" |
Return values
| Return | Effect |
|---|---|
Response |
sent to client; chain ends |
URL |
same-site rewrite, 200, address bar unchanged |
undefined / return; |
skip this function; chain continues |
Endpoint
export default async () =>
new Response("Hello, World!", { headers: { "content-type": "text/html" } });
export const config = { path: "/api/hello" };
Redirect / rewrite
import type { Context } from "@netlify/edge-functions";
export default async (req: Request, { cookies, geo }: Context) => {
if (geo.city === "Paris" && cookies.get("promo-code") === "15-for-followers") {
return Response.redirect(new URL("/subscriber-sale", req.url)); // redirect
// or: return new URL("/subscriber-sale", req.url); // rewrite (same-site only)
}
};
export const config = { path: "/sale" };
Rewrites must target the same site. To reach other sites, use fetch.
Middleware (modify origin response)
import type { Context } from "@netlify/edge-functions";
export default async (request: Request, context: Context) => {
if (new URL(request.url).searchParams.get("method") !== "transform") return;
const response = await context.next();
return new Response((await response.text()).toUpperCase(), response);
};
export const config = { path: "/blog/*" };
Call context.next() only when you need the response body. If you just return undefined, the chain continues on its own.
Conditional requests
export default async (req: Request, { next }: Context) => {
const res = await next({ sendConditionalRequest:
Установить netlify-edge-functions в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл 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.
Как установить скилл netlify-edge-functions?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл netlify-edge-functions запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic