platform
serverless functions
Creating functions
Nhost gives you the option to run serverless functions on the following runtimes:
  • Node.js 14 (Both JavaScript and Typescript)

Every .js and .ts file in the functions/ folder of your Nhost app will be exposed as an HTTP endpoint. You have to
// In functions/hello/[name].js
export default (req, res) => {
  res.status(200).send(`Hello ${req.query.name}!`)
}

Or, if you prefer TypeScript:
// In functions/hello/[name].ts
import { Request, Response } from 'express'

export default (req: Request, res: Response) => {
  res.status(200).send(`Hello ${req.query.name}!`)
}


HTTP endpoints are automatically generated based on the file structure under functions/.
As such, given this file structure:
functions/
  index.js
  users/
    index.ts
    active.ts
  my-company.js

The following endpoints will be available:
If you've used Netlify or Vercel, this routing logic will be familiar to you.

In production, serverless functions are deployed on AWS Lambda.
When developing locally, you must have the correct runtime installed on your machine.