netlify avatar

Netlify Functions

If you're writing serverless functions on Netlify, this walks you through the modern default export pattern (not the old exports.handler), path routing, background jobs, scheduled tasks, and streaming responses. It's most useful when you're building standalone APIs or adding background processing to static sites. If you're using a framework like Next.js or SvelteKit, you probably won't need this since those generate their own functions through adapters. The coverage of the Context object and environment variable handling (Netlify.env, not process.env) is solid. Good reference for timeout limits and when to use the background function suffix pattern.

skills.sh installs
3.5K
GitHub stars
51
last updated
Aug 21, 2026

Install

$ npx -y skills add netlify/context-and-tools --skill netlify-functions --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/netlify/context-and-tools
Categories
Backend & APIs, Documentation, Cloud & Infrastructure
First seen
Jun 3, 2026

More from netlify/context-and-tools

All 14
1trailofbits avatardebug-buttercuptrailofbits/skillsDebugs the Buttercup CRS (Cyber Reasoning System) running on Kubernetes. Use when diagnosing pod crashes, restart loops, Redis failures, resource pressure, disk3.5Kskills.sh installs
2minimax-ai avatarfullstack-devminimax-ai/skillsFull-stack backend architecture and frontend-backend integration guide. TRIGGER when: building a full-stack app, creating REST API with frontend, scaffolding ba3.5Kskills.sh installs
3actionbook avatardomain-webactionbook/rust-skillsUse when building web services. Keywords: web server, HTTP, REST API, GraphQL, WebSocket, axum, actix, warp, rocket, tower, hyper, reqwest, middleware, router, 3.4Kskills.sh installs
4openai avatarcli-creatoropenai/skillsBuild a composable CLI for Codex from API docs, an OpenAPI spec, existing curl examples, an SDK, a web app, an admin tool, or a local script. Use when the user 3.3Kskills.sh installs
5gogf avatargoframe-v2gogf/skillsGoFrame v2 development skill. Use only when the target Go project uses or is explicitly adopting GoFrame v2: the nearest go.mod requires github.com/gogf/gf/v2, 3.3Kskills.sh installs
6browser-use avatarcloudbrowser-use/browser-useDocumentation reference for using Browser Use Cloud — the hosted API and SDK for browser automation. Use this skill whenever the user needs help with the Cloud 3.3Kskills.sh installs