Netlify Functions runtime API
The runtime API for Netlify Functions, compatible with the AWS Lambda runtime API.
The API
The API surface is quite minimal: functions are comprised of handlers that receive a Request and return a Response, using the default export.
export default async (req) => new Response(`Responding to ${req.url}`)
Functions also receive a context object with a series of convenience properties and methods for easy access to common operations and Netlify features.
export default async (req, context) => {
if (req.url === '/move-me') {
return context.redirect('/other-page')
}
return context.json({ hello: 'world' })
}
Development
These are two main artifacts produced by this project:
-
npm module: The API and the Lambda interoperability layer are published as an npm module. To generate the module, run
npm run compile
. -
Lambda Layer: The runtime API is injected into user code using Lambda Layers. To generate the layer ZIP archive, run
npm run build
.