Edge functions
Run TypeScript, Go, or Python at 280+ POPs with sub-30ms cold starts.
Edge functions run as close to your users as the network allows. Halo isolates each invocation in a V8 isolate (TS) or a microVM (Go/Python), and routes requests to the nearest healthy POP.
Create a function
api/hello.ts
tsexport default function handler(req: Request) {
return new Response("hi from " + req.headers.get("x-halo-region"));
}The file path becomes the route. api/hello.ts is reachable at /api/hello after deploy.
Per-region pinning
By default, functions run in every POP. Pin to a region:
export const config = {
regions: ["iad1", "fra1"],
};Runtime: V8 isolates. Cold start: ~5–15ms. Memory: 128 MB max.
Runtime: Firecracker microVM. Cold start: ~25–50ms. Memory: up to 1 GB.
Runtime: Firecracker microVM. Cold start: ~30–60ms. Memory: up to 1 GB.
Streaming responses
export default async function handler() {
const stream = new ReadableStream({
start(controller) {
controller.enqueue(new TextEncoder().encode("first chunk\n"));
setTimeout(() => {
controller.enqueue(new TextEncoder().encode("second chunk\n"));
controller.close();
}, 100);
},
});
return new Response(stream);
}Halo flushes each chunk to the client as soon as it’s enqueued.
Last updated
Edit this page