DEV Community

Alex Spinov
Alex Spinov

Posted on

Hono Has a Free Web Framework That Runs on Every Edge — Cloudflare, Vercel, Deno, Bun, AWS Lambda

The Edge Framework Problem

Express doesn't run on Cloudflare Workers. Fastify doesn't run on Deno Deploy. Each runtime needs its own framework.

Hono runs on every JavaScript runtime. Same code, 10+ deployment targets. Ultra-lightweight: 14KB.

What Hono Gives You

Simple, Express-Like 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');
  return c.json({ id, name: 'John' });
});

export default app;
Enter fullscreen mode Exit fullscreen mode

Middleware

import { cors } from 'hono/cors';
import { logger } from 'hono/logger';
import { bearerAuth } from 'hono/bearer-auth';
import { compress } from 'hono/compress';

app.use('*', logger());
app.use('*', cors());
app.use('/api/*', bearerAuth({ token: 'secret' }));
app.use('*', compress());
Enter fullscreen mode Exit fullscreen mode

Validation (Zod Integration)

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

app.post('/users',
  zValidator('json', z.object({
    name: z.string(),
    email: z.string().email(),
  })),
  (c) => {
    const body = c.req.valid('json'); // Fully typed
    return c.json({ created: true, user: body });
  }
);
Enter fullscreen mode Exit fullscreen mode

JSX Templates

import { Hono } from 'hono';
import { html } from 'hono/html';

const Layout = ({ children }) => html`
  <html><body>${children}</body></html>
`;

app.get('/', (c) => {
  return c.html(
    <Layout>
      <h1>Welcome</h1>
    </Layout>
  );
});
Enter fullscreen mode Exit fullscreen mode

RPC Client (Like tRPC)

// Server
const routes = app.get('/api/posts', (c) => c.json([{ id: 1, title: 'Hello' }]));
export type AppType = typeof routes;

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

const client = hc<AppType>('http://localhost:3000');
const posts = await client.api.posts.$get(); // Typed!
Enter fullscreen mode Exit fullscreen mode

Performance

Hono on Bun: 300K+ requests/sec. On Cloudflare Workers: <1ms cold start.

Runs On

Cloudflare Workers, AWS Lambda, Vercel, Deno, Bun, Node.js, Netlify, Fastly.

Quick Start

npm create hono@latest
Enter fullscreen mode Exit fullscreen mode

Why This Matters

The edge is the future of web apps. Hono gives you a framework that works on every edge runtime — write once, deploy anywhere.


Building edge APIs that need data? Check out my web scraping actors on Apify Store — data at the edge. For custom solutions, email spinov001@gmail.com.

Top comments (0)