- Home
- Skills
- Outfitter Dev
- Agents
- Hono Dev
hono-dev_skill
- TypeScript
25
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill outfitter-dev/agents --skill hono-dev- SKILL.md11.2 KB
Overview
This skill helps you build type-safe Hono APIs, generate OpenAPI docs with Zod, and create end-to-end typed RPC clients using hono/client. It bundles patterns for route chaining, factory-based context typing, centralized error handling, middleware, and testing with testClient. Use it to keep runtime behavior and TypeScript types aligned across server, docs, and client code.
How this skill works
It enforces critical patterns like chaining route definitions so TypeScript preserves full route inference, and exporting AppType = typeof app to derive client types. Use createFactory<Env>() to propagate typed context values through middleware and handlers. Integrations include zValidator for request validation, @hono/zod-openapi for OpenAPI generation, and testClient/hc for typed testing and RPC clients.
When to use it
- Building REST or RPC-style APIs with Hono where end-to-end types matter
- Creating a type-safe client with hono/client from your server AppType
- Generating OpenAPI documentation from Zod schemas and serving Swagger UI
- Writing integration tests with testClient that preserve API types
- Implementing middleware that shares typed context (database, user, requestId)
Best practices
- Always chain route definitions (app.get(...).post(...).put(...)) to preserve type inference
- Export type AppType = typeof app so hc<Client> can infer routes and payloads
- Use createFactory<Env>() for typed middleware state and c.get/c.set usage
- Validate inputs with Zod via zValidator and surface errors centrally with onError
- Test routes with testClient to validate behavior and keep typed request/response shapes
Example use cases
- A microservice exposing typed endpoints and a generated hc client for other services
- An API that publishes OpenAPI JSON from z.object schemas and serves Swagger UI
- A multi-module app where each route file is a factory.createApp() and mounted via .route()
- Integration tests that run against an in-memory DB using testClient to assert responses
- Middleware that injects a typed DB connection, requestId, and authenticated user into handlers
FAQ
Assigning app to a variable then calling app.get/post separately breaks the chain; always chain methods directly when defining routes.
How do I get a typed client for my server?
Export type AppType = typeof app from the server and pass it to hc<AppType>(baseUrl) to get end-to-end typed requests.
How should I validate queries and bodies?
Use zValidator with Zod schemas so c.req.valid('query'|'json') returns fully typed, validated data and errors are mappable in onError.