netlify-functions
Write, configure, and deploy Netlify serverless functions in TypeScript, JavaScript, or Go.
Skill by netlifyOfficial
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/netlify-netlify-functions-cca7de
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, testing, devops, cloud
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
netlify-functions- Description
- 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.
- License
- MIT
- Instructions
- 384 lines in SKILL.md · view on GitHub
Before installing
- Instructions call the network
Files (1)
- SKILL.md
SKILL.md (first lines)
# 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"`.
⚠️ **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`.
```ts title="netlify/functions/hello.mts"
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()`:
```ts
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>`.
```ts title="netlify/functions/travel.mts"
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: `path` supports [`URLPattern`](https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API) 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. `method: ["GET", "POST"]`.
## Fetchable module shape (alternative)
Equivalent to the bare handler; carries `config` inline and lets you add event handlers.
```ts
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.app` is 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 be `undefined`), `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** under `netlify dev` — test with `netlify dev --geo=mock --country=DE`.
### Who is calling: `context.user`
⚠️ `context.user` is often `undefined`: public projects, basic password protection, local `netlify dev`, and functions deployed before October 5, 2026 (redeploy to enable). Always handle it; key records on `id` (`email` may be `undefined`).
```ts title="netlify/functions/whoami.mts"
import type { Config, Context } from "@netlify/functions"
export default async (req: Request, context: Context) => {
if (!context.user) {
// Public project, basic password protection, local CLI, or pre-2026-10-05 deploy.
return Response.json({ user: null }, { status: 401 })
}
return Response.json({
id: context.user.id,
email: context.user.email ?? null,
expiresAt: context.user.expiresAt.toISOString(),
})
}
export const config: Config = { path: "/whoami" }
```
## Config object
Export `const config` (or the `config` property of a Fetchable module):
- `path` / `excludedPath` — `string | string[]`, must start with `/`.
- `method` — one method or array.
- `preferStatic` — `boolean`.
- `background` — `boolean` (see Background).From netlify/context-and-tools, MIT.
More from netlify/context-and-tools
- 0.761score
netlify-frameworks
netlifyOfficial
Deploy and configure web frameworks on Netlify — build settings and SSR/edge adapters plus local platform emulation and env vars.
SkillAFreshness: A★ 43Claude Code +9 - 0.761score
netlify-identity
netlifyOfficial
Add user authentication to a Netlify site with @netlify/identity — signup/login/logout, Google/GitHub/GitLab/Bitbucket OAuth, server-side getUser() checks…
SkillAFreshness: A★ 43Claude Code +9 - 0.761score
netlify-access-control
netlifyOfficial
Picks the right Netlify site-protection layer and disambiguates the three unrelated "auth" concepts users conflate — app-user login (Netlify Identity)…
SkillAFreshness: A★ 43Claude Code +9 - 0.761score
netlify-mcp-servers
netlifyOfficial
Build, deploy, and secure Model Context Protocol (MCP) servers on Netlify.
SkillAFreshness: A★ 43Claude Code +9 - 0.761score
netlify-deploy
netlifyOfficial
Create, configure, and manage Netlify deploys from code — reach for this when setting up Git continuous deployment, running netlify deploy or netlify deploy…
SkillAFreshness: A★ 43Claude Code +9 - 0.761score
netlify-database
netlifyOfficial
Zero-config Postgres for Netlify apps via @netlify/database — querying data from Functions/Edge Functions, writing schema migrations, setting up Drizzle ORM…
SkillAFreshness: A★ 43Claude Code +9 - 0.755score
netlify-agent-runner
netlifyOfficial
Run AI agent tasks remotely on Netlify using Claude, Codex, or Gemini.
SkillAFreshness: A★ 43Claude Code +9 - 0.755score
netlify-edge-functions
netlifyOfficial
Write, route, cache, and debug Netlify Edge Functions, the Deno-based TypeScript or JavaScript handlers in netlify/edge-functions that run at the network edge…
SkillAFreshness: A★ 43Claude Code +9 - 0.755score
netlify-functions
netlifyOfficial
Write, configure, and deploy Netlify serverless functions in TypeScript, JavaScript, or Go.
SkillAFreshness: A★ 43Claude Code +9 - 0.755score
netlify-ai-gateway
netlifyOfficial
Use Netlify AI Gateway to call OpenAI, Anthropic Claude, Google Gemini, TypeSafe (Jev), or OpenRouter-hosted models (xAI/DeepSeek/Meta/Mistral/Qwen) from…
SkillAFreshness: A★ 43Claude Code +9 - 0.755score
netlify-blobs
netlifyOfficial
Store and retrieve unstructured objects, files, and cache-like state on Netlify with the @netlify/blobs module.
SkillAFreshness: A★ 43Claude Code +9 - 0.755score
netlify-caching
netlifyOfficial
Cache dynamic and static responses on Netlify's CDN from Functions, Edge Functions, and proxies.
SkillAFreshness: A★ 43Claude Code +9
Signals
- Stars
- 43
- Forks
- 13
- Open issues
- 3
- Last commit (this folder)
- Oct 22, 2026 (6 days ago)
- Last release
- Oct 8, 2026 (20 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/netlify/context-and-tools
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
- 0.755score
netlify-functions
netlifyOfficial
Write, configure, and deploy Netlify serverless functions in TypeScript, JavaScript, or Go.
SkillAFreshness: A★ 43Claude Code +9 - 0.394score
netlify-functions
netlifyOfficial
Write, configure, and deploy Netlify serverless functions in TypeScript, JavaScript, or Go.
SkillAFreshness: A★ 43Claude Code +9
More from netlify
- 0.761score
netlify-frameworks
netlifyOfficial
Deploy and configure web frameworks on Netlify — build settings and SSR/edge adapters plus local platform emulation and env vars.
SkillAFreshness: A★ 43Claude Code +9 - 0.761score
netlify-identity
netlifyOfficial
Add user authentication to a Netlify site with @netlify/identity — signup/login/logout, Google/GitHub/GitLab/Bitbucket OAuth, server-side getUser() checks…
SkillAFreshness: A★ 43Claude Code +9 - 0.761score
netlify-access-control
netlifyOfficial
Picks the right Netlify site-protection layer and disambiguates the three unrelated "auth" concepts users conflate — app-user login (Netlify Identity)…
SkillAFreshness: A★ 43Claude Code +9 - 0.761score
netlify-deploy
netlifyOfficial
Create, configure, and manage Netlify deploys from code — reach for this when setting up Git continuous deployment, running netlify deploy or netlify deploy…
SkillAFreshness: A★ 43Claude Code +9 - 0.761score
netlify-database
netlifyOfficial
Zero-config Postgres for Netlify apps via @netlify/database — querying data from Functions/Edge Functions, writing schema migrations, setting up Drizzle ORM…
SkillAFreshness: A★ 43Claude Code +9 - 0.761score
netlify-mcp-servers
netlifyOfficial
Build, deploy, and secure Model Context Protocol (MCP) servers on Netlify.
SkillAFreshness: A★ 43Claude Code +9
Cite this page
netlify-functions skill. Agent Mart. https://agentmart.dev/skills/netlify-netlify-functions-cca7de (last updated 2026-10-24)