Type-safe Hono APIs with routing, middleware, RPC. Use for request validation, Zod/Valibot validators, or encountering middleware type inference, validation hook, RPC errors.
View on GitHubsecondsky/claude-skills
hono-routing
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/secondsky/claude-skills/blob/main/plugins/hono-routing/skills/hono-routing/SKILL.md -a claude-code --skill hono-routingInstallation paths:
.claude/skills/hono-routing/# Hono Routing & Middleware
**Status**: Production Ready ✅
**Last Updated**: 2025-11-21
**Dependencies**: None (framework-agnostic)
**Latest Versions**: hono@4.10.6, zod@4.1.12, valibot@1.1.0
---
## Quick Start (5 Minutes)
### Install
```bash
bun add hono@4.10.6 # preferred
# or: bun add hono@4.10.6
```
**Why Hono:**
- **Fast**: Built on Web Standards, runs on any JavaScript runtime
- **Lightweight**: ~10KB, no dependencies
- **Type-safe**: Full TypeScript support with type inference
- **Flexible**: Works on Cloudflare Workers, Deno, Bun, Node.js, Vercel
### Basic App
```typescript
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => {
return c.json({ message: 'Hello Hono!' })
})
export default app
```
**CRITICAL:**
- Use `c.json()`, `c.text()`, `c.html()` for responses
- Return the response (don't use `res.send()` like Express)
- Export app for runtime
### Add Validation
```bash
bun add zod@4.1.12 @hono/zod-validator@0.7.4
```
```typescript
import { zValidator } from '@hono/zod-validator'
import { z } from 'zod'
const schema = z.object({
name: z.string(),
age: z.number(),
})
app.post('/user', zValidator('json', schema), (c) => {
const data = c.req.valid('json')
return c.json({ success: true, data })
})
```
---
## Critical Rules
### Always Do
✅ **Return responses** from handlers (c.json, c.text, c.html, etc.)
✅ **Use c.req.valid('source')** after validation middleware to get typed data
✅ **Export app** for deployment (Cloudflare Workers, Bun, Deno, Node.js)
✅ **Use validation middleware** (zValidator, vValidator) for type-safe request data
✅ **Call await next()** in middleware to pass control to next handler
✅ **Use HTTPException** for expected errors (returns proper HTTP status)
✅ **Use template tag validators** (zValidator, vValidator) not hooks
✅ **Define context types** for custom variables (`Hono<{ Variables: { ... } }>`)
✅ **Use sub-apps** (app.route()) for organizing large APIs
✅ **Type your RPC route