Quickstart
Declare your routes, serve them on your framework, and call them from a typed client in 8 minutes.
Installation
Install kizunajs, your framework's adapter, Zod 4 for the schemas, and the CLI.
2.0 is in pre-release
Kizuna installs from the beta tag until 2.0.0 ships. The 1.x line published under a different name and is no longer maintained, so it
gets no fixes and no security backports.
Enable strict in your tsconfig.json. Kizuna's inference depends on it.
Start with the config
kizuna.config.ts sits at the root of your app. Start with your framework's adapter:
The adapter puts that framework's own request in every handler's args, typed.
Add the generate script
That writes the Config that types everything you declare next. Run it after every change, and kizuna:check in CI.
Say so where it gets read:
Declare the routes
Keep one k for the API and export it:
k is typed by the Config that kizuna:generate writes, so every name you use is checked against what your config declares. See new Kizuna().
Each route pairs a method and path with Zod schemas, and carries the handler that answers it:
The handler's query, body and params are typed from the declaration right above it, and its return is checked against that route's responses.
Kizuna.model names UserSchema, so it lands as User in the generated client and components.schemas.User in the OpenAPI document rather than being written out at each use.
Add them to the config:
Mount it
This is the one step that differs per framework. Express, Fastify and Hono each mount their own way.
Call it from a typed client
Add fetchClient to the config, pointed at the file you want written:
Wrap it once with the base URL you serve on:
A route with more than one status narrows on status:
Next steps
- Routes covers declaring a route and everything its handler receives
- Authentication declares identities and the guards on them, Access Control says who may call each route, and handler types and OpenAPI security follow
- Adapters covers Express, Fastify, Hono, and Next.js setup and options
- Fetch client covers headers, custom fetch, and error handling
- OpenAPI generation serves a spec alongside your API