Public
Like
hono-rpc-zod-starter
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
main.tsx
https://jxnblk--36ca98a2759f4d968268305ce3402a15.web.val.run
Minimal Hono RPC starter example with Zod validation
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.