Guide
Hono vs itty-router vs Worktop: Cloudflare Workers 2026




Hono, itty-router, and Worktop compared for Cloudflare Workers in 2026. Bundle size, performance, middleware, TypeScript support, and which framework to use.
Contents
Contents
TL;DR
Choose Hono for a Cloudflare Workers API that needs typed bindings, middleware and request validation. Choose itty-router for a small routing layer when your built Worker has a tight size budget. Keep worktop when maintaining a Worker that already depends on its request and response helpers.
Key Takeaways
- Hono supports JSX, middleware and Fetch-based deployments, with an adapter for Node.js.
- itty-router offers lightweight routers with a chainable API. Choose a preset based on the hooks and response helpers you need.
- Worktop provides a router and platform utilities for existing Workers applications.
- Performance depends on the deployed Worker. Measure startup and request latency with the same handlers and bindings.
- TypeScript helps type Hono bindings and itty-router's router and request handlers.
Downloads
| Package | npm downloads |
|---|---|
hono | 106,015,460 |
itty-router | 459,181 |
worktop | 477,798 |
The npm API counts downloads from November 23–29, 2026. Use this snapshot as package activity context, alongside runtime fit and the interfaces your Worker needs.
Hono: The Full-Featured Standard
// Cloudflare Worker with Hono:
import { Hono } from 'hono';
import { cors } from 'hono/cors';
import { bearerAuth } from 'hono/bearer-auth';
import { zValidator } from '@hono/zod-validator';
import { z } from 'zod';
type Bindings = {
DB: D1Database; // Cloudflare D1 SQLite
KV: KVNamespace; // Cloudflare KV
R2: R2Bucket; // Cloudflare R2
AI: Ai; // Workers AI
};
const app = new Hono<{ Bindings: Bindings }>();
// Middleware:
app.use('*', cors({ origin: ['https://yourapp.com'] }));
app.use('/api/*', bearerAuth({ token: 'secret-token' }));
// Route with validation:
const createUserSchema = z.object({
email: z.string().email(),
name: z.string().min(2),
});
app.post('/api/users', zValidator('json', createUserSchema), async (c) => {
const { email, name } = c.req.valid('json');
const db = c.env.DB; // Typed D1 binding
const result = await db
.prepare('INSERT INTO users (email, name) VALUES (?, ?) RETURNING id')
.bind(email, name)
.first<{ id: string }>();
return c.json({ id: result?.id, email, name }, 201);
});
// D1 query:
app.get('/api/users', async (c) => {
const users = await c.env.DB
.prepare('SELECT id, email, name FROM users ORDER BY created_at DESC LIMIT 100')
.all<{ id: string; email: string; name: string }>();
return c.json(users.results);
});
// KV cache:
app.get('/api/config', async (c) => {
const cached = await c.env.KV.get('app-config', { type: 'json' });
if (cached) return c.json(cached);
const config = { version: '1.0', features: ['dark-mode', 'analytics'] };
await c.env.KV.put('app-config', JSON.stringify(config), { expirationTtl: 3600 });
return c.json(config);
});
// Workers AI:
app.post('/api/summarize', async (c) => {
const { text } = await c.req.json();
const result = await c.env.AI.run('@cf/meta/llama-3-8b-instruct', {
messages: [{ role: 'user', content: `Summarize: ${text}` }],
});
return c.json({ summary: result.response });
});
export default app;
// wrangler.toml — Workers config:
// name = "my-api"
// main = "src/index.ts"
// compatibility_date = "2024-09-23"
//
// [[d1_databases]]
// binding = "DB"
// database_name = "my-db"
// database_id = "xxx"
//
// [[kv_namespaces]]
// binding = "KV"
// id = "xxx"
# Hono Workers commands:
npm create hono@latest my-app -- --template cloudflare-workers
wrangler dev # Local dev
wrangler deploy # Deploy to Workers
wrangler d1 execute DB --file=./schema.sql # Run migrations
itty-router v4: Ultra-Minimal
Existing Workers on itty-router v4 can keep using Router and router.handle while they plan an upgrade. The v5 migration guide covers the switch to router.fetch and the addition of AutoRouter. The following example uses v5 with Cloudflare Workers bindings.
import { AutoRouter, cors, error, type IRequest } from 'itty-router';
const { preflight, corsify } = cors();
const router = AutoRouter<IRequest, [Env, ExecutionContext]>({
before: [preflight],
catch: () => error(500, 'Internal server error'),
finally: [corsify],
});
router
.get('/api/users', async (_request, env) => {
const users = await env.DB
.prepare('SELECT * FROM users')
.all();
return users.results;
})
.post('/api/users', async (request, env) => {
const body = await request.json<{ email: string; name: string }>();
await env.DB
.prepare('INSERT INTO users (email, name) VALUES (?, ?)')
.bind(body.email, body.name)
.run();
return { success: true };
})
.get('/api/users/:id', async ({ params }, env) => {
const user = await env.DB
.prepare('SELECT * FROM users WHERE id = ?')
.bind(params.id)
.first();
return user ?? error(404, 'User not found');
});
export default router;
Bundle Size Comparison
Hono offers a smaller hono/tiny preset. itty-router has a bare IttyRouter and a fuller AutoRouter preset. With worktop, measure the routing and Workers utilities you import. Build the same endpoint with your deployment tooling and the middleware you need, then compare compressed sizes against your Workers plan limit.
Multi-Runtime: Hono's Superpower
// Hono runs on multiple runtimes — same code:
// Cloudflare Workers:
export default app;
// Node.js (for local testing):
import { serve } from '@hono/node-server';
serve(app, (info) => {
console.log(`Server running on port ${info.port}`);
});
// Bun:
export default { port: 3000, fetch: app.fetch };
// Lambda (via @hono/aws-lambda):
import { handle } from '@hono/aws-lambda';
export const handler = handle(app);
// Edge functions (Vercel, Netlify):
export const config = { runtime: 'edge' };
export default app.fetch;
Hono JSX (Workers UI)
// Hono supports JSX for server-rendered HTML:
import { Hono } from 'hono';
import { html } from 'hono/html';
const app = new Hono();
const Layout = ({ children }: { children: any }) => html`
<!DOCTYPE html>
<html>
<head><title>My Workers App</title></head>
<body>${children}</body>
</html>
`;
app.get('/', (c) => {
return c.html(
<Layout>
<h1>Hello from Cloudflare Workers!</h1>
</Layout>
);
});
// Or with JSX transform (tsconfig: "jsx": "react-jsx"):
app.get('/users', async (c) => {
const users = await c.env.DB.prepare('SELECT * FROM users').all();
return c.html(
<html>
<body>
<ul>
{users.results.map((user: any) => (
<li key={user.id}>{user.name}</li>
))}
</ul>
</body>
</html>
);
});
Decision Guide
Use Hono if:
→ Building a real API (middleware, auth, validation)
→ Need to run same code on multiple runtimes
→ Want type-safe bindings (D1, KV, R2)
→ TypeScript-first project
→ Shared validation across multiple routes
Use itty-router if:
→ Ultra-small bundle size is a hard requirement
→ Simple proxy/redirect logic
→ Reading/writing to KV without complex routing
→ Building edge functions for a CDN (not a full app)
Keep worktop if:
→ An existing Worker depends on its APIs
→ Your tests cover the routes and bindings you maintain
Middleware Architecture and Hono's Ecosystem
Hono ships middleware under subpaths such as hono/cors, hono/bearer-auth and hono/jwt. Install the separate validation adapter that fits your schema library.
The @hono/zod-validator middleware passes the validated type to c.req.valid('json'). Use @hono/zod-openapi when you also want to generate OpenAPI documentation from your route definitions.
In itty-router v5, AutoRouter offers before, catch and finally stages. Use them for CORS preflight, error handling and response headers. Add request validation and authentication where your routes need them.
Hono's multi-runtime capability also changes the testing story significantly. You can test Hono Workers apps using hono/testing with app.request() — no actual HTTP server required. Tests run fast and work identically in Vitest on Node.js and in the Cloudflare Workers test environment via Wrangler's vitest-pool-workers.
Cloudflare Workers Platform Integration Differences
When building on Cloudflare Workers, how a framework exposes platform bindings (D1, KV, R2, Queues, Workers AI) matters more than raw routing performance. Hono's generic Bindings type parameter gives you a clean way to declare your Worker's environment and get full TypeScript IntelliSense on c.env.DB, c.env.KV, etc. The type flows through every route handler and middleware in the app, so you never get a type error when accessing a binding that's declared in wrangler.toml.
itty-router handles bindings through function parameters — the Worker's env object is passed as the second argument to route handlers. This works but doesn't compose as cleanly with middleware that also needs access to bindings. You end up threading env through more manually, or relying on closure scope, which gets messy in larger codebases.
Cloudflare's official examples and templates now consistently use Hono for Workers APIs. The npm create hono@latest scaffolding generates a cloudflare-workers template with D1, KV, and AI bindings pre-configured, wrangler.toml set up, and a working test setup using vitest-pool-workers. This scaffolding quality gap versus itty-router's minimal documentation is meaningful for teams new to the Workers platform.
If Worker startup affects your latency targets, compare the deployed builds with the same bindings and dependencies. Measure startup separately from the time spent serving a request.
Migrating from itty-router to Hono
If you have an existing itty-router project and want to migrate to Hono, the route handler signatures are similar enough that migration is usually straightforward. The main conceptual difference is that itty-router passes (request, env, ctx) as positional arguments while Hono uses a single context object c with c.req, c.env, and c.executionCtx. A typical itty-router handler (req, env) => env.KV.get(req.params.key) becomes (c) => c.env.KV.get(c.req.param('key')) in Hono.
itty-router's response helpers (json(), error(), status()) map to Hono's c.json(), c.text(), and c.newResponse(). The AutoRouter's finally: [json] transformer (which auto-wraps plain object returns as JSON) doesn't have a direct equivalent in Hono, but Hono middleware can add a response transformer with similar behavior if you rely on that pattern heavily.
If size is a migration constraint, try hono/tiny and measure the compressed build with your real routes and middleware.
Compare Hono, itty-router, and Worktop download trends on PkgPulse.
When to Use Each
Use Hono if:
- You want a full-featured web framework that works across Cloudflare Workers, Bun, Node.js, and Deno
- You need middleware, JWT auth, validation, and RPC client generation
- You are building a multi-route API with production-level requirements
- You want TypeScript support with typed routes and response types
- Your team needs documentation, examples, and a mature ecosystem
Use itty-router if:
- Your Worker has a tight bundle budget
- You want the absolute minimum routing layer with no overhead
- Your Worker has a small set of routes with minimal middleware
- You need a router for an edge function or service worker environment
Use worktop if:
- Your Workers project uses the Service Worker API syntax (
addEventListener('fetch', ...)) - You want a router that integrates with the older Cloudflare Workers API style
- You have an existing worktop codebase you're maintaining
In 2026, Hono is the default recommendation for new Cloudflare Workers projects — it provides the best balance of features, performance, and developer experience across all edge runtimes. itty-router remains a valid choice when bundle size is a hard constraint.
Both Hono and itty-router support the native Request/Response Web API, making them portable across Cloudflare Workers, Deno, Bun, and any standard-compliant edge runtime without code changes.
Hono's RPC client feature (@hono/client) is underutilized but powerful for full-stack TypeScript applications. When you define Hono routes with explicit response types using c.json() and Zod validation, the RPC client can infer the exact response shape for each route — giving you end-to-end type safety from the Cloudflare Worker to the browser client without a code generation step or a separate API schema file. The workflow is: define the Hono app with typed routes, export the app type, and import that type into your frontend client code. hc<AppType>('https://api.example.com') creates a client where client.api.users.$get() returns a typed response inferred directly from your route handler's return type. This is the Workers equivalent of tRPC — no schema, no codegen, just TypeScript types flowing from server to client. For teams building monorepo applications with a Cloudflare Worker backend and a Next.js or React frontend, this pattern eliminates an entire category of frontend-backend type drift bugs.
A Hono behavior that surprises developers coming from Express is route matching precision. Hono's router (internally called RegExpRouter or SmartRouter) matches routes in registration order for the same path pattern, but parameterized segments like :id are always less specific than literal segments. /api/users/me will correctly match before /api/users/:id even if registered after it, because Hono scores specificity. Express resolves /api/users/me as :id = "me" if the parameterized route was registered first. This Hono behavior is correct for REST APIs but requires verifying route order if you have both literal routes and parameterized routes for the same path prefix. In itty-router, route matching is strictly first-match, so registration order is the developer's responsibility.
Source notes
See also: Fastify vs Hono and Express vs Hono, Hono vs itty-router: Edge-First API Frameworks Compared.