ScriptsApr 3, 2026·2 min read

Hono — Ultrafast Web Framework for the Edge

Tiny, fast web framework for Cloudflare Workers, Deno, Bun, and Node.js. Perfect API layer for AI services. 29K+ GitHub stars.

Agent ready

Safe staging for this asset

This asset is staged first. The copied prompt tells the agent to inspect the staged files and ask before activating scripts, MCP config, or global config.

Stage only · 17/100Policy: stage
Agent surface
Any MCP/CLI agent
Kind
Script
Install
Stage only
Trust
Trust: Established
Entrypoint
hono.md
Safe staging command
npx -y tokrepo@latest install ff72c952-86a4-402d-b288-7468b3a3f4c5 --target codex

Stages files first; activation requires review of the staged README and plan.

TL;DR
Hono is a lightweight web framework running on Cloudflare Workers, Deno, and Bun.
§01

What it is

Hono is an ultrafast, lightweight web framework designed for edge computing runtimes. It runs on Cloudflare Workers, Deno, Bun, AWS Lambda, Fastly, and Node.js with the same codebase. The framework weighs under 14KB, starts in milliseconds, and provides a familiar Express-like API with TypeScript-first design.

It targets developers building APIs, web applications, and AI service backends that need to run close to users on edge infrastructure with minimal latency.

§02

How it saves time or tokens

Hono lets you write one API codebase and deploy it to any edge or serverless platform. Instead of learning platform-specific APIs for each cloud provider, you use Hono's unified routing, middleware, and response helpers. For AI applications, this means building lightweight proxy APIs, rate limiting layers, or model routing services that deploy globally on edge networks with sub-millisecond cold starts.

§03

How to use

  1. Create a new project:
npm create hono@latest my-app
cd my-app
npm install
  1. Define routes:
import { Hono } from 'hono';

const app = new Hono();

app.get('/', (c) => c.text('Hello Hono'));
app.get('/api/health', (c) => c.json({ status: 'ok' }));

export default app;
  1. Deploy to your platform:
# Cloudflare Workers
npx wrangler deploy

# Or run locally with any runtime
npx hono dev src/index.ts
§04

Example

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

const app = new Hono();

app.use('/api/*', cors());
app.use('/api/*', bearerAuth({ token: 'my-secret-token' }));

// AI model proxy endpoint
app.post('/api/generate', async (c) => {
    const { prompt, model } = await c.req.json();
    
    const response = await fetch('https://api.openai.com/v1/chat/completions', {
        method: 'POST',
        headers: {
            'Authorization': `Bearer ${c.env.OPENAI_KEY}`,
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            model: model || 'gpt-4o',
            messages: [{ role: 'user', content: prompt }]
        })
    });
    
    return c.json(await response.json());
});

export default app;
§05

Related on TokRepo

§06

Common pitfalls

  • Edge runtimes have memory and execution time limits. AI inference tasks that take more than a few seconds or need large models should run on dedicated servers, not edge functions.
  • Not all Node.js APIs are available on every edge runtime. Test your middleware and dependencies on your target platform before deploying.
  • Hono's ecosystem is smaller than Express's. Check if the middleware you need exists before starting a project. Many common patterns (CORS, auth, rate limiting) are built-in.

Frequently Asked Questions

Which runtimes does Hono support?+

Hono runs on Cloudflare Workers, Deno, Bun, Node.js, AWS Lambda, Fastly Compute, Vercel Edge, Netlify Edge, and Lagon. You write the same code and change only the entry point adapter for each platform. This portability avoids vendor lock-in.

How does Hono compare to Express.js?+

Hono is significantly faster and smaller than Express. It uses a RegExpRouter for fast route matching, weighs under 14KB, and is designed for edge runtimes that Express does not support. Hono provides similar middleware patterns but with TypeScript-first design and better type inference.

Can I use Hono for AI applications?+

Yes. Hono works well as a lightweight API layer for AI applications -- model proxy endpoints, rate limiting, request routing, and authentication. Deploy it on edge networks for low-latency API access globally. Keep heavy computation (model inference) on dedicated GPU servers.

Does Hono support WebSocket?+

Yes. Hono provides WebSocket support through runtime-specific adapters. On Cloudflare Workers, it uses Durable Objects for WebSocket connections. On other runtimes, it delegates to the platform's native WebSocket support. This enables real-time features like streaming AI responses.

Is Hono suitable for full-stack applications?+

Yes. Hono includes JSX support for server-side rendering, static file serving, and template rendering. You can build full-stack apps with Hono, though for complex frontend UIs, pairing Hono as a backend API with a dedicated frontend framework is more common.

Citations (3)
🙏

Source & Thanks

Created by Yusuke Wada. Licensed under MIT.

hono — ⭐ 29,700+

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets