Skip to main content
BurgerAPI

BurgerAPI

BurgerAPI is a Bun-first TypeScript framework for building modern APIs, with file-based routing, inferred type safety, validation, WebSocket, plugins, and automatic OpenAPI. Build the same app for Bun, Node.js, Cloudflare Workers, Deno, or Vercel with one CLI flag.

Bun NativeMITOpen Sourcev1.0.0-betaBun 1.4.4+159stars
import { Burger } from "burger-api";
const burger = new Burger({
apiDir: "api",
});
burger.serve(4000);

Why BurgerAPI

Everything you need to ship APIs

A focused toolkit for Bun backends: routing, validation, WebSocket, OpenAPI, and lifecycle hooks that work together out of the box.

File-Based Routing

Define routes with route.ts files. Dynamic segments use [param] and wildcards use [...], all declarative and convention-driven.

Hybrid Router

On Bun, serve() registers every route (static, :param, wildcard) as a per-method native Bun route. The fetch handler path (Cloudflare, Deno, Vercel, Node) uses a fast radix matcher.

Zod Validation

Define schemas next to your routes. Validate params, query, headers, cookies, and body with full type inference and clear errors.

WebSocket

File-based WebSocket routes under src/websocket/. Native support on Bun, Node.js, Cloudflare Workers, and Deno, with typed connections through ws.data and ws.services.

Plugins

Register plugins in src/plugins.ts. Official packages cover jwt-auth, api-key, session, oidc, basic-auth, and env.

Providers

Declare shared services in src/providers.ts. They become typed ctx.services in every handler and hook.

Automatic OpenAPI

OpenAPI 3.0 is generated from your routes and Zod schemas, so the specification always matches the code.

Lifecycle Hooks

Six named hooks control every request: onRequest, transform, beforeRoute, afterRoute, mapResponse, and onError.

TypeScript First

defineRoute(schema, handler) infers ctx.validated straight from your Zod schema, so there's no generic to write by hand.

Bun Native

Built for Bun from the ground up. Use the runtime's HTTP server, router, and tooling without abstraction layers.

Deploy Anywhere

burger-api build --target=cloudflare|deno|vercel|node generates the entry and platform config for you: WinterCG-compatible, no manual wiring.

Lean by Design

Lazy query and cookie parsing, a shared request context, and AOT route builds keep allocations and latency low.