Functions

Serverless & Edge Functions

Deploy TypeScript or WebAssembly to 280+ POPs. Cold starts under 10ms, no Docker required.

Create a function

bash
novaabase functions new hello
functions/hello/index.ts
export default async (req: Request) => {
  const { name = "world" } = await req.json().catch(() => ({}));
  return Response.json({ message: `Hello, ${name}!`, time: Date.now() });
};

Deploy

bash
novaabase functions deploy hello --no-verify-jwt
novaabase functions list

Invoke

typescript
const { data, error } = await nb.functions.invoke("hello", {
  body: { name: "Ada" },
});

Edge Functions

Edge functions run inside our global router, closest to the user, with access to Postgres over a pooled connection.

functions/geo/index.ts
export default async (req: Request, ctx: { country: string; city: string }) => {
  return Response.json({ hello: ctx.city ?? "earth" });
};

export const config = { runtime: "edge", regions: "all" };

Scheduled functions (cron)

bash
novaabase functions schedule cleanup --cron "0 3 * * *"