Agent skill · practicalswan

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, 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.

What it needs

About 11k tokens when loaded.

What this skill does

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). 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 index or matches the subdirectory name. All of these create a function hello: netlify/functions/hello.mts netlify/functions/hello/hello.mts netlify/functions/hello/index.mts Use .mts (TS) / .mjs (JS) for ES modules. .cts/.cjs force CommonJS; .ts/.js follow the nearest package.json "type". Minimal function No config export. Serves at /.netlify/functions/hello. Install types: npm install @netlify/functions (required for TS types; optional for JS). Read env vars and secrets with Netlify.env.get(): 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>. Multiple paths: path: ["/cats", "/dogs"]. Patterns: path supports URLPattern syntax — path: ["/sale/", "/item/:sku"]. Named groups land on context.params. For the query string use req.url. excludedPath: carve exceptions, e.g. excludedPath: ["/product/.css"] with path: "/product/". preferStatic: true: let a real static file at the URL win. method: restrict methods, e.g. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills practicalswan/netlify-functions

View the source on GitHub

Browse the @skills marketplace