netlify-functions

Write and configure Netlify serverless functions in TypeScript, JavaScript, or Go.

Updated May 19, 2026
One-click install
npx skills add https://github.com/costrict-plugins-repo/anthropic-netlify-skills --skill netlify-functions-costrict-plugins-repo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: netlify-functions
Source: https://github.com/costrict-plugins-repo/anthropic-netlify-skills/tree/main/codex/skills/netlify-functions
Command: npx skills add https://github.com/costrict-plugins-repo/anthropic-netlify-skills --skill netlify-functions-costrict-plugins-repo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @netlify/functions.

What problem does it solve? Adding backend logic to a Netlify site requires knowing the correct function file layout, handler signature, routing config, and platform limits — getting any of these wrong leads to broken endpoints, unbundled files, or unexpected billing. This Skill provides the exact patterns for writing, routing, and deploying Netlify Functions correctly. ## Core Features & Use Cases - Modern handler API: Export a default async handler taking a web Request and Netlify Context, returning a Response, with typed access to params, geo, cookies, and environment variables via Netlify.env.get(). - Routing and config: Custom path/excludedPath URLPattern routing, method restrictions, rate limiting, region and memory/vCPU settings, and cache purging with purgeCache(). - Specialized function types: Streaming responses (60s, 20 MB), background jobs up to 15 minutes, scheduled cron functions in UTC, and typed platform-event handlers for deploy, Identity, and form events. - Use Case: Build a contact form API endpoint at a custom path, a nightly cron job that generates a digest at 9 AM ET, and a long-running background function that processes uploads — all with correct limits and config. ## Quick Start Create a Netlify serverless function in TypeScript that returns JSON at a custom route and reads an API key from environment variables.

Frequently Asked Questions about netlify-functions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Netlify serverless function in TypeScript?

Create a `.mts` file in `netlify/functions/` that exports a default async handler taking a `Request` and Netlify `Context` and returning a `Response`. Install `@netlify/functions` for types; the function serves at `/.netlify/functions/<name>` by default.

How do I route a Netlify function to a custom URL path?

Export a `config` object with a `path` property using URLPattern syntax, such as `path: "/travel-guide/:city/:country"`. Named groups become `context.params`, and the function then serves only at that path, not the default `/.netlify/functions/` URL.

What is the difference between background and scheduled Netlify functions?

Background functions (`config.background: true`) return an immediate 202 and run up to 15 minutes. Scheduled functions use a cron expression in UTC, run only on published deploys, and are limited to 30 seconds of execution.

Why does my Netlify function fail to read files in production?

Files read from disk at runtime with `fs.readFile` are not bundled, so they work under `netlify dev` but throw ENOENT in production. Import static data as a module or declare the files with `included_files` in `netlify.toml`.

Can I set response headers for Netlify functions in netlify.toml?

No. `[[headers]]` in `netlify.toml`, `_headers`, and redirect header rules apply only to static CDN responses. Function response headers must be set in code on the returned `Response` object.

What are the payload and execution limits of Netlify functions?

Synchronous execution is limited to 60 seconds, buffered payloads to 6 MB (about 4.5 MB binary after Base64), streamed responses to 20 MB, and background payloads to 256 KB. The combined environment-variable limit is roughly 4 KB.