Hono RPC Zod Starter

Minimal Hono RPC starter example with Zod validation

View demo

How it works

The main.tsx module is the main entrypoint and defines all routes for the Hono server. The API routes define Zod schemas for validation. This module exports the AppType type based on the routes for the client.tsx module to use. The server HTML response includes a <script> that imports the client.tsx module.

The client.tsx module imports the AppType type along with hc from hono/client to create the client instance. This module demonstrats fetching all cats from the API, adding a new cat, and refetching the results.

It then tries to create a cat without a name, which throws a Zod error.

View more starters