Gatsby Functions help you build Express-like backends without running servers.
src/api/* are mapped to function routes like files in
src/pages/* become pages.
For example, the following Function is run when you visit the URL
A Function file must export a single function that takes two parameters:
- req: An instance of http.IncomingMessage with some automatically parsed data
- res: An instance of http.ServerResponse with some helper functions
Dynamic routing is supported for creating REST-ful APIs and other uses cases
Query strings and common body content types are automatically parsed and available at
Read more about supported data formats.
Sometimes you want to respond differently to GETs vs. POSTs or only respond to one method.
Site environment variables are used to pass secrets and environment-specific configuration to Functions.