Tirne β Write high-performance APIs in one file. Built for Bun. Type-safe by design. Cold starts under 1ms.
Explore the full guide to Tirne β a Bun & Edge-native web framework built for speed, structure, and zero boilerplate.
π https://tirne.dev
β‘ Sub-millisecond APIs. First-class control of side effects. π Star Tirne on GitHub
Tirne is a declarative, type-safe framework for Bun β designed to make side effects explicit and performance predictable.
npx create-tirne-app- Bun
- Cloudflare Workers
This command sets up a ready-to-run Tirne project in seconds.
π£ Love minimal tools that get out of your way? Star the main Tirne repo: https://github.com/Tirne-ts/Tirne
A zero-boilerplate project, tailored for your runtime:
index.tswith a working router and a/endpoint- Runtime config files (
bunfig.toml,wrangler.toml) package.jsonwith minimal scripts and dependencies
Example output:
β Choose your target environment: βΊ Bun
β Project folder: βΊ my-tirne-app
β
Tirne app created in 'my-tirne-app'
Next steps:
cd my-tirne-app
bun install # or npm install
npm run dev (Bun) # or wrangler dev Tirne is built on 5 core principles: E
- Structure as code β Routes, middleware, and logic are configuration, not behavior. Code is a manifest, not a script.
- Errors are values β TirneErrors carry type, status, and intent. They are thrown, but not hidden.
- Composition over convention β Middleware is composed explicitly, and order is part of the contract.
- Types shape behavior β The structure and safety of your API are defined by its types, not docs.
- Designed for the edge β Built for Bun, optimized for fetch, born in the millisecond age.
- β Structure-first routing β Define your entire API as a single declarative structure
- β
Composable middleware β Explicit
compose()flow, no decorators or global scope - β
Structured errors β Throw
TirneErrorwith type, status, and visibility - β
Built-in response helpers β
json(),html(),text(),error()γetc... β clean and consistent - β Edge-native execution β Instant cold start & sub-ms response on Bun, Workers, and Deno
- β No boilerplate β No CLI, no config, no directory rules. Just pure code.
- β Type-safe by design β Routes, handlers, errors, all shaped by TypeScript
All tests were performed using Bun v1.1.0 on an M2 Pro chip (macOS), simulating edge runtime conditions.
| Metric | Result | Interpretation |
|---|---|---|
| βοΈ Cold Start | 0.02 ms |
π§ Essentially unmeasurable β perfect for edge/fetch-based runtimes |
| β‘οΈ First Request | 0.79 ms |
π Beats the 1ms barrier. Ideal for latency-critical APIs |
| π Requests/sec | 90,489 rps |
π₯ Comparable to Hono, surpasses Express by 10x+ |
| π Avg Latency | 0.96 ms |
β‘ Sub-millisecond under load β suitable for interactive apps |
| π¦ Throughput | 10.9 MB/sec |
π Handles large JSON payloads with ease |
| π― Total Requests | 905,000 in 10s |
πͺ Battle-tested for real-world load |
β¨ Tirne was designed for edge-first, zero-warmup environments β and these numbers prove it.
import { Server,json,setCookie,requireAuth } from "tirne";
import type { Route } from "tirne";
const routes: Route[] = [
{
method: "GET",
path: "/login",
handler: () => {
const headers = new Headers();
headers.append("Set-Cookie", setCookie("auth", "valid-token", {
httpOnly: true,
path: "/",
maxAge: 3600,
}));
return json({ message: "Logged in" }, 200, headers);
},
middleware: [],
},
{
method: "GET",
path: "/private",
handler: () => json({ message: "Secret data only for authenticated users" }),
middleware: [requireAuth],
},
];
const server = new Server(routes);
export default {
fetch: (req: Request) => server.fetch(req),
};
A backend should be transparent, fast, and designed like architecture β not like magic. Tirne is built on five modern principles:
-
Structure is the source of truth
APIs are defined as code, not behavior. No decorators, no conventions β just configuration you can read. -
Errors are data, not chaos
Exceptions carry type, status, and visibility. You donβt catch them β you design them. -
Composition is everything
Middleware is composed explicitly. No global state, no stack traces from hell. -
Built for the edge, shaped by types
Tirne runs instantly on Bun, Workers, and Deno. And your types shape what runs β not your docs. -
No bootstraps, no boilerplate, no BS
One file. No CLI. No hidden magic. What you write is what you deploy.
| Axis | Tirne β¨ | Hono πΏ | Elysia π§ |
|---|---|---|---|
| Philosophy | Structure and Side Effect Control | Simplicity and Familiarity | Type-maximalism and Decorator DSL |
| Routing | Declarative Route[] structure |
Chain-style app.get("/foo") |
Macro-enhanced handler declarations |
| Middleware | Explicit compose([...]), scoped per route |
Global app.use() and nested routers |
Plugin + lifecycle hooks + decorators |
| Error Model | TirneError: structured error with metadata |
throw or return c.text() |
set.status() with plugin-driven handling |
| Type Safety | Type-driven config and handlers (Route<T>) |
Medium (context-specific typing) | Extremely strong, but tightly coupled to tools |
| Response API | json(), error() as pure return values |
c.json(), c.text() methods |
set.response() side-effectful injections |
| Extensibility | Middleware and composition primitives | Plugins with shared context | Plugins + Macros + Decorators |
| Dependencies | π’ Zero external runtime deps | π‘ Lightweight | π΄ Heavy: valibot, macros, SWC, etc. |
| Runtime Support | β Bun / Workers γ γγγγγγγγγγγ | β Bun / Node / Workers/ Deno | β Bun-only, limited to SWC macro pipelines |
| Ideal Users | API designers, type-aware minimalists, edge devs | Express/Deno users wanting familiar DX | TS power users who love macros & decorators |
Tirne is not just minimal β it's architectural. It gives you full control over structure, type, and execution without opinionated tooling or hidden behaviors.
bun add tirneTo use in Workers :
npm install tirneTirne is ideal for:
-
β‘οΈ Need edge-speed APIs β Sub-millisecond response times on Bun, Workers, and Deno.
-
π¦ Want type-driven reliability β APIs shaped by types, not runtime guesswork.
-
π Deploy on modern runtimes β Runs fetch-first, works anywhere: Bun, Node, Workers, Deno.
-
π§ͺ Design with side effects in mind β Control cookies, headers, and auth with intention.
π If youβre tired of magic, macros, and monoliths β try Tirne.
π βοΈ Star on GitHub to join the movement.
Apache 2.0
