📝 Edit page
➕ Add page
Basic
A greeting example of using Netlify Functions
Function setup
Create these files then push to trigger a Netlify build.
netlify.toml. The build command must be set - the docs recommend a comment if you have nothing else.[build] functions = "functions" command = "#"functions/hello.js. (Or atfunctions/hello/index.jsOrfunctions/hello/hello.js.)exports.handler = function (event) { const respData = { message: "Hello World" eventData: event } return { statusCode: 200, body: JSON.stringify(respData) }; }
Use query parameters like ?myParam=foo.
const myParam = event.queryStringParameters.myParam;
Testing
Then when deployed you query the Lambda at a path like /.netlify/functions/hello.
https://example.netlify.com/.netlify/functions/hello{"message": "Hello World"}
Breakdown of the URL:
/.netlify/functions- this is a fixed path and cannot be configured.hellois based on the JS script name.