Skip to main content
Version: v10.0.0

HonoSchema

Converts the type of a Hono app into a Hyper Fetch SDK schema for createSdk .

Every route becomes a Request whose response, JSON payload, query params and endpoint come from the Hono route definition and its validators. Path segments become nested properties,

:param segments become $param properties, and kebab-case segments become camelCase.

Routes below an optional :param? segment appear both without and with the param, and regex params like :id{[0-9]+} become plain $id properties. The endpoint is the one createSdk

sends the request to, so a trailing slash and the regex patterns of the Hono path are dropped. An .all() route gets every standard method, like in Hono's own client.

Pass the type of the app returned by your route chain, including apps mounted with

app.route() and basePath() . Anything that is not a Hono app resolves to {} .

Routes handled by upgradeWebSocket() are not requests, so they are left out - connect to them with a

Socket and check the address with HonoSocketPath . Server-Sent Events routes ( streamSSE() ) stay in the schema as a $get with an untyped response: Hono types them like any other raw Response .


Import
import { HonoSchema } from "@hyper-fetch/hono"

Preview​

type HonoSchema<App,Client> = App extends HonoBase<any, infer S, any, any> ? Prettify<ConvertSchema<MergeUnionToRecord<S>, Client>> : {};