Overview
Learn how to use Nhost Functions
All you have to do is throw your .js
and .ts
files inside of the ./functions
folder of your project and Nhost takes care of deploying your functions as part of a Deployment.
Nhost Functions
Endpoints
Functions are exposed through HTTP endpoints generated based on the contents of ./functions
:
File | HTTP Endpoint |
---|---|
functions/index.js | https://[subdomain].functions.[region].nhost.run/v1/ |
functions/users/index.ts | https://[subdomain].functions.[region].nhost.run/v1/users |
functions/users/active.ts | https://[subdomain].functions.[region].nhost.run/v1/users/active |
functions/my-company.js | https://[subdomain].functions.[region].nhost.run/v1/my-company |
Environment Variables
Environment variables are available to your Functions. Both in production and when running Nhost locally using the Nhost CLI.
The same environment variables that are used to configure event triggers can be used to authenticate functions.
Billing
Functions are billed per GB-sec or GB-hour. 1 GB-hour is 3600 GB-seconds.
1 GB-sec is 1 Function with 1GB of RAM running for 1 second. If 1 Function with 1GB of RAM runs for 3600 seconds, that’s the equivalent of 1 GB-hour.