Skip to content

Getting Started

serverless functions getting started TypeScript JavaScript HTTP endpoints deployment
  • An Nhost project connected to a GitHub repository
  • The Nhost CLI installed for local development

Place a .js or .ts file inside the ./functions directory of your project:

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

Start the Nhost CLI and call your function:

curl https://local.functions.local.nhost.run/v1/hello?name=World

Push your code to the connected GitHub repository. Nhost automatically deploys your functions as part of a Deployment.

A more complete example that returns request metadata:

import process from 'node:process'
import type { Request, Response } from 'express'
export default (req: Request, res: Response) => {
res.status(200).json({
headers: req.headers,
query: req.query,
node: process.version,
arch: process.arch,
invocationId: req.invocationId,
})
}