netlify-functions
БесплатноБез исполняемых скриптовНе проверенWrite, configure, and deploy Netlify serverless functions in TypeScript, JavaScript, or Go. Use this when adding an API endpoint or backend route, adding a…
от netlify★ 58 звёзд на GitHubОб этом скилле
Netlify Functions
Reach for the modern default-handler API (.mts TypeScript). Export a default async handler taking a web Request and a Netlify Context, returning a web Response. Avoid the legacy AWS Lambda handler shape unless writing Go or migrating old code (see Legacy at the end).
Building an app's backend? Start with Netlify Server, a long-lived server that holds connections open and keeps state between requests; use functions alongside it for individual tasks, scheduled jobs, and events. See When to use a server.
File locations
- Default directory:
netlify/functions/(relative to base directory). Keep it outside your publish directory or source files ship as static assets. - A function is one file or a subdirectory whose entry file is named
indexor matches the subdirectory name. All of these create a functionhello:netlify/functions/hello.mtsnetlify/functions/hello/hello.mtsnetlify/functions/hello/index.mts
- Use
.mts(TS) /.mjs(JS) for ES modules..cts/.cjsforce CommonJS;.ts/.jsfollow the nearestpackage.json"type".
⚠️ Same-name JS and TS files: the JS one wins. If the functions directory has e.g. items.js and items.ts, the JavaScript function is deployed and the TypeScript file is silently ignored — edits to the .ts have no effect. Keep one file per function name; delete or rename the stale .js when moving a function to TypeScript.
Minimal function
No config export. Serves at /.netlify/functions/hello.
import type { Context } from "@netlify/functions"
export default async (req: Request, context: Context) => {
return new Response("Hello, world!")
}
Install types: npm install @netlify/functions (required for TS types; optional for JS).
Read env vars and secrets with Netlify.env.get():
const apiKey = Netlify.env.get("STRIPE_SECRET_KEY")
Never hardcode secrets. For the variable to exist at runtime its scope must include Functions. Variables set in netlify.toml are NOT available to functions. Values are frozen per deploy — change them and redeploy to apply.
Response headers are set in code on the returned Response. headers in netlify.toml, _headers, and redirect header rules apply ONLY to static CDN responses, not function responses. Do not add CORS headers unless explicitly requested.
Custom path routing
Set config.path to route to custom URLs. When set, the function serves ONLY at that path — not at /.netlify/functions/<name>.
import type { Config, Context } from "@netlify/functions"
export default async (req: Request, context: Context) => {
const { city, country } = context.params
return new Response(`You're visiting ${city} in ${country}!`)
}
export const config: Config = {
path: "/travel-guide/:city/:country",
}
- Multiple paths:
path: ["/cats", "/dogs"]. - Patterns:
pathsupportsURLPatternsyntax —path: ["/sale/*", "/item/:sku"]. Named groups land oncontext.params. For the query string usereq.url. excludedPath: carve exceptions, e.g.excludedPath: ["/product/*.css"]withpath: "/product/*".preferStatic: true: let a real static file at the URL win.method: restrict methods, e.g.method: ["GET", "POST"].
Fetchable module shape (alternative)
Equivalent to the default function; carries config inline and lets you add event handlers.
import type { NetlifyFunction } from "@netlify/functions"
export default {
fetch: (req, context) => new Response("Hello, world!"),
config: { path: "/hello" },
} satisfies NetlifyFunction
Context object
Second handler argument (or getContext() from @netlify/functions when out of handler scope — throws outside a request; wrap in try/catch).
context.params— named path params.context.geo—city,country.code/name,latitude,longitude,subdivision,timezone,postalCode.context.ip— client IP string.context.cookies—get(name)/set(options)/delete(name|options). Cross-subdomain cookies need a custom domain (netlify.appis on the Public Suffix List).context.site—id,name,url.context.deploy—context,id,published,skewProtectionToken.context.account.id.context.server.region.context.requestId.context.user— the Netlify user who logged in to a private or team-login-protected project:id,email(may beundefined),expiresAt(Date). See below.context.waitUntil(promise)— run work after the response is sent (analytics, logs) without blocking. Billing/log duration counts until the promise settles. Available for functions deployed on/after 2025-03-20.
⚠️ context.geo/context.ip are mocked
Установить netlify-functions в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл netlify-functions?
Write, configure, and deploy Netlify serverless functions in TypeScript, JavaScript, or Go. Use this when adding an API endpoint or backend route, adding a contact form handler, wiring auth or Identity signup/login hooks, identifying which Netlify user is calling a private or team-login-protected app, building streaming or AI-proxy responses, scheduling cron jobs, running long background jobs (batch processing/scraping), reacting to deploy or form events, setting up rate limiting or region/memory config, or reading environment variables and secrets inside a function. Covers file locations, the Request/Context/Response handler shape, path routing, config options, and local testing with netlify dev.
Как установить скилл netlify-functions?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл netlify-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