StealThis .dev

Bun + Hono API Starter

Lightweight API starter with Bun runtime and Hono framework — blazing fast HTTP, TypeScript-first, with middleware, routing, and zero config.

Open in Lab
bun hono typescript
Targets: HTML

Code

A minimal API starter that combines the Bun runtime with the Hono web framework. Bun provides sub-millisecond startup and native TypeScript execution; Hono provides a tiny, Web Standard API-based router with a rich middleware ecosystem.

Why Bun + Hono?

Bun is a JavaScript runtime built from scratch on JavaScriptCore (the engine behind Safari). It includes a bundler, test runner, and package manager — all significantly faster than their Node.js equivalents. TypeScript and JSX work without any transpilation config.

Hono (meaning “flame” in Japanese) is an ultralight web framework that runs on any JS runtime — Bun, Deno, Cloudflare Workers, Node.js. It uses Web Standard Request/Response objects, so your code is portable across platforms without changes.

Quick Start

bun create hono@latest -- --template bun
cd my-app
bun run dev

That is it. No tsconfig.json tweaking, no build step, no compilation. Bun runs TypeScript natively.

Key File: src/index.ts

import { Hono } from "hono";
import { logger } from "hono/logger";
import { cors } from "hono/cors";

const app = new Hono();

app.use("*", logger());
app.use("/api/*", cors());

app.get("/", (c) => c.json({ message: "Hello Hono!" }));
app.get("/api/health", (c) => c.json({ status: "ok" }));

export default app;

Extending the Starter

  • Drizzle ORM — type-safe SQL with Bun’s built-in SQLite or PostgreSQL
  • Zod + @hono/zod-validator — request body/query validation with automatic types
  • @hono/zod-openapi — generate OpenAPI specs from your Zod schemas
  • hono/jwt — JWT authentication middleware

References