DEV Community

Alex Spinov
Alex Spinov

Posted on

Hono Has a Free Web Framework That Runs on Every JavaScript Runtime

Express is tied to Node.js. Fastify is tied to Node.js. Hono runs on Cloudflare Workers, Deno, Bun, Node.js, AWS Lambda, and Vercel Edge — all with the same code. It's ultrafast, type-safe, and built for the edge.

What Hono Gives You for Free

  • Multi-runtime — same code runs on Cloudflare Workers, Deno, Bun, Node.js, Lambda
  • Ultra-lightweight — 14KB core, tree-shakeable to ~3KB
  • Type-safe routing — path params and query strings are typed
  • Built-in middleware — CORS, JWT, rate limiting, compression, caching
  • Zod validation — validate request bodies with @hono/zod-validator
  • RPC client — type-safe API client generated from your routes
  • JSX — server-side rendering without React

Quick Start

npm create hono@latest my-app
Enter fullscreen mode Exit fullscreen mode

Basic API

import { Hono } from 'hono';

const app = new Hono();

app.get('/', (c) => c.text('Hello Hono!'));

app.get('/api/users/:id', (c) => {
  const id = c.req.param('id'); // Typed!
  return c.json({ id, name: 'Alice' });
});

app.post('/api/users', async (c) => {
  const body = await c.req.json();
  return c.json({ created: true }, 201);
});

export default app;
Enter fullscreen mode Exit fullscreen mode

Zod Validation

import { zValidator } from '@hono/zod-validator';
import { z } from 'zod';

const createUserSchema = z.object({
  name: z.string().min(2),
  email: z.string().email(),
  role: z.enum(['admin', 'user']),
});

app.post(
  '/api/users',
  zValidator('json', createUserSchema),
  async (c) => {
    const data = c.req.valid('json'); // Fully typed!
    const user = await db.users.create({ data });
    return c.json(user, 201);
  }
);
Enter fullscreen mode Exit fullscreen mode

RPC Client (tRPC-Like Type Safety)

// server.ts
const routes = app
  .get('/api/users', async (c) => {
    const users = await db.users.findMany();
    return c.json(users);
  })
  .post('/api/users', zValidator('json', createUserSchema), async (c) => {
    const data = c.req.valid('json');
    return c.json(await db.users.create({ data }));
  });

export type AppType = typeof routes;

// client.ts
import { hc } from 'hono/client';
import type { AppType } from './server';

const client = hc<AppType>('http://localhost:3000');

// Fully typed! Auto-complete works.
const users = await client.api.users.$get();
const newUser = await client.api.users.$post({ json: { name: 'Bob', email: 'bob@test.com', role: 'user' } });
Enter fullscreen mode Exit fullscreen mode

Middleware

import { cors } from 'hono/cors';
import { jwt } from 'hono/jwt';
import { rateLimiter } from 'hono/rate-limiter';
import { compress } from 'hono/compress';

app.use('*', cors());
app.use('*', compress());
app.use('/api/*', jwt({ secret: process.env.JWT_SECRET }));
Enter fullscreen mode Exit fullscreen mode

Deploy Anywhere (Same Code)

// Cloudflare Workers
export default app;

// Node.js
import { serve } from '@hono/node-server';
serve(app);

// Bun
export default app; // Bun.serve compatible

// Deno
Deno.serve(app.fetch);

// AWS Lambda
import { handle } from 'hono/aws-lambda';
export const handler = handle(app);
Enter fullscreen mode Exit fullscreen mode

Hono vs Express vs Fastify

Feature Hono Express Fastify
Size 14KB 200KB 300KB
Runtime All Node only Node only
TypeScript Native @types needed Good
Validation Zod plugin Manual Ajv
RPC client Built-in None None
Edge support Native None None
Req/sec (Bun) 130K 45K 70K

The Verdict

Hono is the Express replacement for 2026. Faster, smaller, type-safe, and it runs everywhere. If you're building APIs — especially for edge runtimes — Hono is the modern choice.


Need help building production web scrapers or data pipelines? I build custom solutions. Reach out: spinov001@gmail.com

Check out my awesome-web-scraping collection — 400+ tools for extracting web data.

Top comments (0)