hono-idioms
Learn idiomatic Hono patterns for building type-safe HTTP APIs across any runtime. This skill covers router composition, middleware ordering, request validation with Zod, error handling, and end-to-end typed RPC clients—all without code generation.
hono-idioms teaches you Hono routing, middleware composition, and Zod validation for building type-safe HTTP APIs.
AI-generated summary based on this skill's SKILL.md
Install
irahardianto/awesome-agv/hono-idioms · repository language: JavaScript
git clone https://github.com/irahardianto/awesome-agv
cp -r awesome-agv/.agents/skills/hono-idioms ~/.claude/skills/hono-idiomsnpx skillfed install irahardianto/awesome-agv/hono-idiomsFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What are the core hono routing patterns for type-safe HTTP APIs?
hono-idioms teaches you to build type-safe HTTP APIs using Hono's routing system. Start with basic routes (app.get, app.post) and progress to composable sub-routers via app.route(). Use path parameters with type inference, organize handlers with middleware chains, and leverage TypeScript's type system throughout. Hono infers types from your handler signatures automatically—no code generation needed.
How do you implement end-to-end type-safe RPC without code generation?
hono-idioms shows how to build typed RPC clients by defining your server routes with strict types, then deriving client types directly from those definitions. Use Hono's type exports to create a client that mirrors your server's shape. This approach eliminates code generation overhead while maintaining full type safety across the network boundary.
How to use hono with typescript for middleware composition?
hono-idioms covers middleware composition by chaining handlers with app.use() and organizing them in order. Each middleware can set context variables via c.set() and read them with c.get(), passing typed data down the chain. Compose custom middleware with createMiddleware(), apply request validation using zValidator with Zod schemas, and handle errors with HTTPException for consistent responses.
What does hono streaming SSE implementation look like?
hono-idioms teaches streaming responses and Server-Sent Events by using c.streaming() to send data over time. Return a ReadableStream or async generator to emit tokens or events incrementally. This pattern works across Hono's multi-runtime support (Node.js, Deno, Cloudflare Workers, etc.), letting you build real-time features without runtime-specific code.
What hono handler anti-patterns should you avoid?
hono-idioms highlights common mistakes: forgetting middleware order (validation before handlers), mixing sync and async without proper error boundaries, mutating context incorrectly, and ignoring type inference. Follow idiomatic practices: order middleware logically, use c.set/c.get for typed context, validate early, throw HTTPException for errors, and let TypeScript catch type mismatches before runtime.
How do you organize multi-feature Hono applications with sub-routers?
hono-idioms shows building composable sub-routers by creating separate router instances for each feature (e.g., users, posts) and mounting them with app.route('/prefix', router). Each sub-router has its own middleware and handlers. Use basePath for API versioning, organize by domain, and keep middleware scoped to relevant routes. This scales cleanly across large applications.
SKILL.md
rendered from the published skill — quoted content, verbatim
Hono Idioms and Patterns
Core Philosophy
Hono rewards thin handlers, middleware composition, multi-runtime portability, and end-to-end type safety. Idiomatic Hono = typed routes, validator middleware, RPC client — no code generation needed.
> Scope: Hono-specific patterns. For TypeScript fundamentals: @.agents/skills/typescript-idioms/SKILL.md. For project structure: @.agents/skills/hono-idioms/references/project-structure.md.
Router and Route Organization
- Create apps with
new Hono()and method routing: ```typescript // ✅ Group by resource, compose with app.route() const tasks = new Hono() .get('/', listTasks) .post('/', createTask) .get('/:id', getTask) .put('/:id', updateTask) .delete('/:id', deleteTask);
const app = new Hono() .route('/api/tasks', tasks) .route('/api/users', users); ```
- Use
app.route('/prefix', subApp)to compose sub-routers — each feature exports its ownHono
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 2 files
.agents/skills/hono-idioms/SKILL.md
.agents/skills/hono-idioms/references/project-structure.md