~/docs/backends/functions

Dashboard

Backends

Functions

Write, deploy and call functions that run next to your backend.

Updated

2026-12-02

Source

apps/web/docs/backends/functions.mdx

Write one

terminal

npx @pherwerz/cloud new function hello

phz/functions/hello/index.ts

import type { FunctionHandler } from '@pherwerz/cloud/functions';

const handler: FunctionHandler = async (req, ctx) =>
  Response.json({ hello: 'world' });

export default handler;

Run it locally

terminal

npx @pherwerz/cloud serve

Runs phz/functions with hot reload, with secrets from phz/.env.local. It needs Deno or Docker.

Deploy and call it

terminal

npx @pherwerz/cloud deploy functions   # every function that changed

ts

const { data, error } = await phz.functions.invoke('hello', {
  body: { name: 'world' },
});

rollback function <name> <version> makes an earlier version live again. Secrets are set with phz secrets set NAME=value.