Amba

Functions

Customer serverless functions for Amba — write a TypeScript handler, run it locally with hot reload, and ship it to your project's edge runtime.

Amba functions are small TypeScript HTTP handlers that run on Amba's edge runtime. Each function receives a Request and returns a Response. Use them for webhook handlers, custom mutation endpoints, queue consumers, and scheduled jobs.

Handler shape

Export a default async (req: Request) => Response:

// functions/hello.ts
export default async function (req: Request): Promise<Response> {
  const url = new URL(req.url);
  const name = url.searchParams.get('name') ?? 'world';
  return new Response(JSON.stringify({ greeting: `hello, ${name}` }), {
    headers: { 'content-type': 'application/json' },
  });
}

That's the entire surface. Standard Request / Response / Headers / URL / fetch / crypto are available at runtime.

What you can do in a function

  • Custom HTTP endpoints — anything you'd put behind a server route: webhook receivers, signed-URL minters, server-only mutations.
  • Reads + writes against your collections — call into your project from the handler. Server context bypasses client-side scoping, so you can implement cross-user reads when you need them.
  • Queue consumers — bind a function to a queue with amba functions consume <queue> <function> and it receives one message per delivery.
  • Cron jobs — register a schedule with amba functions schedule <name> "<cron>" and the runtime invokes the function on that cadence.
  • Read secrets — set with amba secrets set NAME value, read with process.env.NAME. Secrets are scoped per-project and never leak cross-tenant.

Three commands you'll use most

The full command list is on the CLI reference.

Limits

  • Bundle sizeamba functions deploy reports the bundle size and rejects deploys over the platform cap. Use --dry-run to triage size without uploading.
  • Per-function rate limits — optional, declared at deploy time with --rate-limit-window, --rate-limit-max, --rate-limit-key. The edge runtime enforces them pre-dispatch (the handler never runs for rate-limited requests).
  • Runtime stdlib — standard Request/Response/Headers/URL/ crypto/fetch are provided by the platform. Node-specific built-ins (fs, child_process, net) are not.

Next

On this page