Client Usage in Hono
From the Hono cheat sheet · RPC Client · verified Jul 2026
Client Usage
Use the type-safe RPC client
typescript
// client.ts
import { hc } from 'hono/client'
import type { AppType } from './server'
const client = hc<AppType>('http://localhost:8787')
// GET request
const res = await client.users.$get()
const data = await res.json() // Typed!
// GET with path params
const user = await client.users[':id'].$get({
param: { id: '123' }
})
// POST with JSON body
const created = await client.users.$post({
json: { name: 'John', email: 'john@example.com' }
})
// Check status
if (created.status === 201) {
const newUser = await created.json()
}💡 hc<AppType>(baseUrl) creates typed client
⚡ Path params: client.users[":id"].$get({ param: {} })
📌 JSON body: $post({ json: {} }), query: $get({ query: {} })
🎯 InferRequestType/InferResponseType for type extraction