netlify-functions
Installation
SKILL.md
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
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".
Minimal function
No config export. Serves at /.netlify/functions/hello.
import type { Context } from "@netlify/functions"