Type-Safe Client in Hono
From the Hono cheat sheet · RPC Client · verified Jul 2026
Type-Safe Client
Create a type-safe API client from your Hono app
typescript
// server.ts
import { Hono } from 'hono'
import { zValidator } from '@hono/zod-validator'
import { z } from 'zod'
const app = new Hono()
.get('/users', (c) => c.json({ users: [] }))
.get('/users/:id', (c) => {
const id = c.req.param('id')
return c.json({ id, name: 'John' })
})
.post('/users',
zValidator('json', z.object({
name: z.string(),
email: z.string().email(),
})),
(c) => {
const data = c.req.valid('json')
return c.json({ id: '123', ...data }, 201)
}
)
export type AppType = typeof app
export default app💡 Chain methods (.get().post()) for proper type inference
⚡ Export "typeof app" as AppType for client usage
📌 Validation schemas are reflected in client types
🎯 Works with route groups via .route()