honojs/hono architecture diagram
How honojs/hono is built, drawn from its code at 61f7c59 on 2026-11-08 by Plotix's agent.
Architecture
What Hono is made of and who talks to whom.
Open the picture for full size (SVG).
Parts
- App developer
- Hono core
get/post/use route methods · fetch() entry point - Routers
SmartRouter by default · Regexp, trie, pattern, linear - Middleware compose
koa-style next() chain · onError / onNotFound - Context
req, res, env · json / text / html helpers - HonoRequest
wraps the Web Request · params, query, body - Validator
validator() middleware · typed input checks - Built-in middleware
cors, jwt, logger · compress, csrf, etag - Helpers
cookie, css, html · streaming, websocket, ssg - JSX renderer
server render to string · jsx/dom client render - Typed client
hc() typed fetch calls - Runtime adapters
cloudflare-workers, bun, deno · aws-lambda, vercel, netlify · service-worker, lambda-edge - Web Standards
How they connect
- App developer → Hono core app.get(), app.fetch()
- Hono core → Routers match(method, path)
- Hono core → Middleware compose run handler chain
- Hono core → Context create per request
- Context → HonoRequest
- Middleware compose → Built-in middleware runs each handler
- Validator → Context
- Helpers → Context
- JSX renderer → Context
- Typed client → Hono core HTTP request
- Runtime adapters → Hono core app.fetch(request, env)
- Hono core → Web Standards
- Runtime adapters → Web Standards
Routers
How a request path is matched to route handlers. SmartRouter tries routers in order and keeps the first that accepts the routes.
Open the picture for full size (SVG).
Parts
- Hono core
- Router contract
add(method, path, handler) · match(method, path) - SmartRouter
tries routers in order · locks onto the first that fits - RegExpRouter
fastest: one regex per method - TrieRouter
prefix tree, general fallback - PatternRouter
pattern-based matching - LinearRouter
linear scan, simplest - UnsupportedPathError
signals: this router cannot take the path
How they connect
- Hono core → SmartRouter match(method, path)
- SmartRouter → RegExpRouter try first
- SmartRouter → TrieRouter fallback
- SmartRouter → PatternRouter fallback
- SmartRouter → LinearRouter last resort
- RegExpRouter → UnsupportedPathError throws on unsupported path
- RegExpRouter → Router contract
- TrieRouter → Router contract
- PatternRouter → Router contract
- LinearRouter → Router contract
- SmartRouter → Router contract
Request flow
What happens to one request inside Hono.fetch(), from entry to Response.
Open the picture for full size (SVG).
Parts
- Incoming request
- Resolve path
- Match route handlers
- Single handler?
- Call handler directly
- Compose middleware chain
- Run middleware and handler
- Error thrown?
- errorHandler builds response
- Response finalized?
- notFoundHandler: 404
- Response out
How they connect
- Incoming request → Resolve path
- Resolve path → Match route handlers
- Match route handlers → Single handler?
- Single handler? → Call handler directly yes
- Single handler? → Compose middleware chain no
- Call handler directly → Response out
- Compose middleware chain → Run middleware and handler
- Run middleware and handler → Error thrown?
- Error thrown? → errorHandler builds response yes
- Error thrown? → Response finalized? no
- errorHandler builds response → Response out
- Response finalized? → Response out yes
- Response finalized? → notFoundHandler: 404 no
- notFoundHandler: 404 → Response out
Runtimes
Where a Hono app runs. Each adapter wraps app.fetch() for one runtime.
Open the picture for full size (SVG).
Parts
- HTTP requests
- Cloudflare Workers
- Cloudflare Pages
- Lambda@Edge
- AWS Lambda
- Vercel
- Netlify
- Bun server
- Deno server
- Service worker
How they connect
- HTTP requests → Cloudflare Workers app.fetch()
- HTTP requests → Cloudflare Pages app.fetch()
- HTTP requests → Lambda@Edge app.fetch()
- HTTP requests → AWS Lambda app.fetch()
- HTTP requests → Vercel app.fetch()
- HTTP requests → Netlify app.fetch()
- HTTP requests → Bun server app.fetch()
- HTTP requests → Deno server app.fetch()
- HTTP requests → Service worker app.fetch()
Core types
The main data shapes passed between routing and request handling.
Open the picture for full size (SVG).
Parts
- Route
method: string · path: string · handler: H · basePath: string - Match result
handlers: [H, params][] · paramStash: string[] - Context
req: HonoRequest · res: Response · env: Bindings · finalized: boolean
How they connect
- Route → Match result matched by
- Context → Match result holds
Draw your own repo
Plotix's agent reads your code and draws its architecture, and the diagram warns you when the code moves on.
Try Plotix