Type-Safe API Client
Learn how to use the type-safe API client with Hono RPC.
Overview
ZeroStarter leverages Hono RPC to provide end-to-end type safety between the backend API and frontend client. This ensures that API calls are fully typed, catching errors at compile time and providing excellent developer experience with autocomplete and type checking.
Type-Safe API Client
This starter utilizes Hono RPC to provide end-to-end type safety between the backend and frontend.
- Backend: Routes defined in
api/hono/src/routersare exported asAppTypeatapi/hono/src/index.ts. - Frontend: The client at
web/next/src/lib/api/client.tsinfersAppTyperequest/response types usinghono/client.
Usage Example
import { apiClient } from "@/lib/api/client"
// Fully typed request and response
const res = await apiClient.health.$get()
const data = await res.json()