@tank/hono-mastery
Installation
SKILL.md
Hono Mastery
Core Philosophy
- Web Standards first — Hono uses only Web Standard APIs (Request, Response, fetch). Code written for one runtime runs on every runtime without adaptation.
- TypeScript types are the contract — Chain handlers to preserve type inference. Avoid separating handlers into "controllers" because path params and middleware types break. Use
c.req.param()inline where types flow. - Middleware is the composition layer — Every cross-cutting concern (auth, CORS, logging, validation) is middleware. Register with
app.use()by path, compose withcreateMiddleware()for type safety. - RPC replaces hand-written API clients — Export
typeof appand usehc<AppType>()on the client. The Zod validator schema becomes the single source of truth for both request validation and client types. - Adapters bridge runtimes — Write one Hono app, deploy anywhere. Each runtime adapter translates its entry point to Hono's
fetch(request, env, ctx)signature.
Quick-Start: Common Problems
"How do I structure a larger Hono app?"
- Create sub-apps per domain:
const users = new Hono()with chained handlers - Mount with
app.route('/users', users)in the main entry - For RPC, chain routes:
const routes = app.route('/users', users).route('/posts', posts) - Export the type:
export type AppType = typeof routes-> Seereferences/routing-and-context.md