Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Functions

Generally Available

Functions run your server-side code as bounded HTTP handlers: Request → Response. Every function receives a standard Web API request and returns a response—streaming included. There is no background execution, built-in retries, or cron scheduling inside Functions; use Jobs for durable work.

Three runtime adapters ship at v0:

  • WASM — In-process via Wasmtime; sub-100ms cold starts when precompiled.
  • Bun — TypeScript/JavaScript with a warm subprocess pool.
  • Lambda — Remote AWS execution via Function URLs and the Lambda Web Adapter.

Deploy and promote are separate steps: push a bundle, verify it materializes, then promote to swap live traffic. This prevents broken builds from reaching production.

  • Web Standard contractfetch(req) → Response (Bun) or WASI HTTP (WASM).
  • Streaming responses — First-class; AI and SSE workloads supported from day one.
  • Versioned bundles — Every deployment stored in Storage; rollback to any prior version.
  • Per-function secrets — Encrypted environment variables injected at invoke time.
  • Invoke policies — Restrict by method, path, time window, or custom rules.
  • Unified observabilityX-Reactor-Function, X-Reactor-Cold-Start, and X-Reactor-Duration-Ms headers on every response.

Create a Bun function, deploy a bundle, promote it, and invoke.

functions/hello/code/index.ts:

export default {
async fetch(request: Request): Promise<Response> {
const { name = 'World' } = await request.json().catch(() => ({}));
return Response.json({ message: `Hello, ${name}!` });
},
};
Terminal window
reactor functions create hello --runtime bun
reactor functions deploy hello --dir ./functions/hello
reactor functions promote hello
reactor functions invoke hello --json '{"name":"Reactor"}'

Secrets are encrypted at rest and never returned by the admin API.

Terminal window
reactor functions env set hello STRIPE_SECRET_KEY --secret
reactor functions env set hello STRIPE_PUBLIC_KEY sk_live_...
reactor functions deploy hello --dir ./functions/hello
reactor functions promote hello

Reference secrets in your manifest:

{
"name": "hello",
"runtime": "bun",
"entrypoint": "code/index.ts",
"env_keys": ["STRIPE_PUBLIC_KEY"],
"secret_keys": ["STRIPE_SECRET_KEY"]
}
// Inside your function handler
export default {
async fetch(): Promise<Response> {
const stream = new ReadableStream({
async start(controller) {
for (let i = 0; i < 10; i++) {
controller.enqueue(`data: ${JSON.stringify({ chunk: i })}\n\n`);
await new Promise((r) => setTimeout(r, 200));
}
controller.close();
},
});
return new Response(stream, {
headers: { 'Content-Type': 'text/event-stream' },
});
},
};
Terminal window
reactor functions deployments list hello
reactor functions rollback hello --to-deployment dep_01HZ...
[functions]
workdir = "./.reactor/functions"
data_key = "base64-32-byte-key"
bundle_max_bytes = 52428800 # 50 MiB
invoke_default_timeout_ms = 30000
invoke_max_timeout_ms = 300000
bun_idle_ttl_secs = 300
bun_max_instances_per_fn = 8
# Runtimes to enable (comma-separated: wasm,bun,lambda)
runtimes = ["wasm", "bun"]
[functions.storage]
url = "http://localhost:8003"
api_key = "storage-api-key-for-system-bucket"
[functions.lambda]
region = "us-east-1"
role_arn = "arn:aws:iam::123456789012:role/reactor-lambda"
bundle_s3_bucket = "reactor-function-bundles"
lwa_layer_arn = "arn:aws:lambda:us-east-1:753240598075:layer:LambdaAdapterLayerX86:..."
LimitWASMBunLambda
Default timeout30s30s30s (max 900s)
Max timeout300s300s900s
Memory range32–1024 MB64–2048 MB128–10240 MB
Bundle size50 MiB50 MiB50 MiB
Cold start (p50)~50ms~200ms~300ms (no PC)
Warm latency (p50)~5ms~15ms~30ms
Max concurrencyPer manifestPer manifestReserved concurrency optional

Manifest concurrency block:

{
"concurrency": {
"min_instances": 0,
"max_concurrency": 50
}
}

When concurrency cap is hit, Reactor returns 429 too_many_requests with Retry-After: 1.

MethodPathDescription
*/fn/v1/{name}Invoke function
*/fn/v1/{name}/{*sub}Invoke with sub-path
POST/fn/v1/_admin/functionsCreate function
POST/fn/v1/_admin/functions/{name}/deploymentsUpload bundle
POST/fn/v1/_admin/functions/{name}/promoteSwap live traffic
GET/fn/v1/_admin/functions/{name}/logsStream logs (SSE)

The deployment is still materializing or failed. Check deployment status and logs before promoting again.

Terminal window
reactor functions deployments list hello
reactor functions logs hello --follow

The handler exceeded limits.timeout_ms. Optimize long operations or move them to a Job. For Lambda, also verify the AWS function timeout matches.

Concurrency cap reached. Increase max_concurrency in the manifest or implement client-side backoff using the Retry-After header.

Your handler threw an uncaught exception. Check function logs—the platform response includes deployment_id and duration_ms in error details.

Ensure env_keys and secret_keys in the manifest exist in function env before deploying. The server recomputes bundle_sha256—client-provided hash must match.