Hono: Routes, Context & Middleware
Hono is a small, fast web framework with an Express-like API, designed to run across multiple JavaScript runtimes -- Cloudflare Workers, Deno, Bun, Node.js, AWS Lambda -- without relying on Node-specific APIs.
Basic Routing
import { Hono } from 'hono'
const app = new Hono()
app.get('/users/:id', (c) => {
const id = c.req.param('id')
return c.json({ id, name: 'Ada' })
})
export default appThe Context Object
The context object (c) bundles request access (c.req), response helpers (c.json, c.text), and a way to pass data between middleware and handlers (c.set/c.get).
Middleware
app.use('/api/*', async (c, next) => {
const token = c.req.header('Authorization')
if (!token) return c.text('Unauthorized', 401)
await next()
})
// Runs in registration order -- placing an auth check before
// a route handler ensures unauthenticated requests are rejected firstWeb Standards, Not a Custom Model
Hono builds around the standard Request/Response Web API objects, rather than Node's http.IncomingMessage/ServerResponse model -- a core reason it runs consistently across many modern JS runtimes.
Keep your own version of these notes — editable, searchable, and organised by your stack.
Start free