DEV Community

Cover image for Iโ€™m 13 and I built a Bun framework thatโ€™s 2x faster than Express ๐Ÿš€
Little Prince
Little Prince

Posted on

Iโ€™m 13 and I built a Bun framework thatโ€™s 2x faster than Express ๐Ÿš€

Itโ€™s a 97kB (2.4kB gzipped) Bun-native framework that hits 21,748 req/s.

๐Ÿ‘‘ Why PrinceJS?

Most "fast" frameworks are just bare-bones routers. PrinceJS is a Super-Framework. Itโ€™s tiny but has "batteries included":

โœ… Built-in SQLite ORM (Powered by Bun.sqlite)
โœ… Native Cron Scheduler (No extra npm packages needed)
โœ… Functional JSX Rendering (Clean UI without the React bloat)
โœ… OpenAPI/Swagger Generation (Auto-sync your docs)
โœ… Validation with Zod

โšก The Benchmarks (oha -c 100 -z 30s)

On an Intel i7-6600U, PrinceJS matches the giants:

Framework Req/s Size (Gzipped)
PrinceJS 21,748 2.4 kB
Hono 22,124 7.5 kB
Elysia 25,312 64.8 kB
Express 9,325 ~2 MB

๐Ÿ› ๏ธ Minimalist DX


typescript
import { prince } from "princejs";
import { Html, Body, H1, render } from "princejs/jsx";

const app = prince();

app.get("/", () => render(
  Html(Body(H1("Hello from PrinceJS!")))
));

app.listen(3000);
Enter fullscreen mode Exit fullscreen mode

Top comments (4)

Collapse
 
trinhcuong-ast profile image
Kai Alder

2.4kB gzipped with a built-in ORM, cron scheduler, AND JSX rendering? That's a wild feature density for the bundle size. Most frameworks pick two of those and already blow past 50kB.

A couple questions since I'm curious about the internals:

  1. How are you handling the SQLite ORM? Is it just a thin wrapper around Bun's native bun:sqlite or did you build a query builder with migration support?

  2. The functional JSX approach is interesting โ€” are you using Bun's built-in JSX transform, or did you roll your own? Because if it's just string concatenation under the hood (which is totally valid for server rendering), that'd explain how you keep the size down.

  3. For the benchmarks โ€” were these all running the same route handler (just returning a string/JSON)? Would be cool to see numbers with middleware chains and the ORM doing actual queries, since that's where frameworks usually diverge.

Keep shipping. At 13 you're building stuff most devs in their 20s haven't attempted.

Collapse
 
godie profile image
Diego Mendoza

That so amazing, do you have a working project using this framework, could you share an a TODO list project or something.

Collapse
 
topeogunleye profile image
topeogunleye

great work, champ.

Collapse
 
thelittleprince1218 profile image
Little Prince

thanks boss