Hono vs Elysia vs Express di Bun runtime
3 web framework untuk Bun. Hono = portable + battle-tested. Elysia = Bun-native + TypeScript-first. Express = legacy compat. Saya pakai ketiganya, verdict berbeda.
TL;DR
- Hono: Recommended untuk most SaaS API. Portable (Bun + Node + Deno + Cloudflare Workers), mature, RPC client built-in.
- Elysia: Recommended kalau Anda sure tidak akan pindah runtime. Bun-native, performance terbaik, TypeScript-first.
- Express: Skip untuk project baru. Legacy compatibility only.
Konteks
API server untuk 3 klien Indonesia, 2024-2026:
- SaaS klinik dental BSD: Hono di Bun, deploy Cloudflare Workers
- SaaS billing fotograf: Elysia di Bun, deploy Hetzner VPS
- Internal tool kontraktor: Express di Node, deploy Hetzner VPS (legacy, sudah ada team Express)
Hono
Apa itu: Web framework yang focus on portability + edge runtimes.
Pro:
- Run di Bun, Node, Deno, Cloudflare Workers, Vercel Edge, AWS Lambda — same code.
- Middleware ecosystem matang (auth, CORS, logger, cache, RPC client)
- Hono RPC: type-safe client-server (mirip tRPC tapi via Hono routing)
- Active development, ~3 release per bulan
- Documentation excellent
Con:
- Performance bagus tapi tidak yang terbaik di Bun (Elysia ~10-15% lebih cepat untuk hot path)
- Some Bun-specific features tidak diekspos (e.g., Bun.serve options)
Bila pakai: API server yang mungkin perlu pindah runtime di masa depan. Atau project yang Anda mau deploy ke edge (Cloudflare Workers).
Elysia
Apa itu: Web framework yang Bun-native, TypeScript-first.
Pro:
- Performance terbaik di Bun runtime (TechEmpower benchmark mengukuhkan ini)
- TypeScript inference yang sangat baik (compile-time type checking untuk route + middleware)
- Schema validation built-in (replace Zod kalau Anda mau)
- Elysia plugin ecosystem cocok untuk Bun-specific use case (file upload, WebSocket, SSE)
Con:
- Bun-only: tidak run di Node, Deno, Cloudflare Workers. Vendor lock-in (ke Bun).
- Ecosystem lebih kecil dari Hono (~30% library coverage)
- Documentation OK tapi tidak se-comprehensive Hono
- Breaking changes lebih sering (Elysia masih < 1.0 stability promise)
Bila pakai: SaaS API yang Anda commit ke Bun, dan butuh max performance. Atau Anda super-suka TypeScript inference dan willing to lock-in.
Express
Apa itu: Veteran web framework JavaScript sejak 2010.
Pro:
- Most mature ecosystem (literally everything has Express middleware)
- Familiar untuk dev Node senior
- Battle-tested at scale (Netflix, Uber, banyak company pakai di production)
Con:
- Tidak TypeScript-first: setiap middleware butuh typing manual atau community types
- Performance lagging: di Bun, Express 30-40% lebih lambat dari Hono atau Elysia
- API design dated: callback + middleware pattern, tidak modern async/await idiomatic
- Stagnant: Express 5 baru release 2024 after 10+ tahun. Express 4 banyak deprecation.
Bila pakai: only kalau legacy team / project. Untuk project baru: tidak ada alasan pilih Express di 2026.
Benchmark
Setup: simple JSON API dengan 1 middleware (CORS) + 1 route (/api/users/:id return JSON).
Hardware: Hetzner CX21 (2 vCPU, 4GB RAM, Singapore).
| Framework | Runtime | Req/sec | p50 latency | p99 latency |
|---|---|---|---|---|
| Hono | Bun 1.3 | 142,000 | 0.4ms | 2.1ms |
| Elysia | Bun 1.3 | 168,000 | 0.3ms | 1.8ms |
| Express | Bun 1.3 | 89,000 | 0.8ms | 4.2ms |
| Express | Node 22 | 76,000 | 1.0ms | 5.1ms |
| Hono | Node 22 | 118,000 | 0.5ms | 2.8ms |
| Hono | Cloudflare Workers | 95,000 | 1.2ms | 4.5ms |
Elysia menang single-runtime (Bun). Hono compete with same numbers di Bun + Node + CF Workers.
Express signifikan tertinggal di kedua runtime.
DX comparison
Hono — example
import { Hono } from 'hono';
import { logger } from 'hono/logger';
import { cors } from 'hono/cors';
const app = new Hono();
app.use(logger(), cors());
app.get('/users/:id', async (c) => {
const id = c.req.param('id');
const user = await db.users.findById(id);
return c.json(user);
});
export default app;
Elysia — example
import { Elysia, t } from 'elysia';
const app = new Elysia()
.use(cors())
.get('/users/:id', async ({ params: { id } }) => {
return await db.users.findById(id);
}, {
params: t.Object({ id: t.String() })
});
export default app;
Express — example (untuk reference)
import express from 'express';
import cors from 'cors';
const app = express();
app.use(cors());
app.get('/users/:id', async (req, res) => {
const user = await db.users.findById(req.params.id);
res.json(user);
});
export default app;
Elysia paling concise dengan type inference build-in. Hono lebih portable. Express paling familiar.
Migration cost
Hono ↔ Elysia: 2-4 jam untuk simple API. Both pakai modern async patterns.
Hono → Express atau Elysia → Express: 4-8 jam (Anda kehilangan type safety, perlu add manual typing).
Express → Hono: 6-12 jam untuk medium API (~30 routes). Worth kalau Anda planning pindah ke Bun atau edge.
Verdict per shape API
| Shape | Recommended |
|---|---|
| SaaS API + butuh portability | Hono |
| Bun-only, max performance | Elysia |
| Edge-first (Cloudflare Workers) | Hono |
| Legacy migration | Express (stay) OR Hono (migrate) |
| Project baru, no constraint | Hono (safer) atau Elysia (bolder) |
Yang surprising
Klien fotograf saya pilih Elysia awalnya karena performance benchmark. Setelah 8 bulan production, kami discover bahwa performance bottleneck bukan di web framework — bottleneck di database query + image processing. Web framework menyumbang < 5% dari total request latency.
Pelajaran: pilih web framework based on DX + portability, bukan benchmark mikro. Performance differences (10-20%) di framework level rarely matter untuk SMB Indonesia API.
Verdict
Recommended: Hono untuk default new project. Bun atau Node atau CF Workers — sama-sama work.
- Pilih Elysia kalau Anda yakin di Bun forever dan butuh squeeze max performance + TS inference.
- Skip Express untuk new project. Hanya stay kalau migration cost lebih tinggi dari benefit.
Ditulis oleh Asti Larasati