How It Works
The type-safe API flow consists of three parts:Backend exports AppType
Routes defined in
api/hono/src/routers are composed into a single AppType that describes the entire API surface.api/hono/src/index.ts
Frontend imports AppType
The client infers request/response types from
AppType using Hono’s hc client.web/next/src/lib/api/client.ts
API Client Usage
Basic GET Request
The health check endpoint demonstrates a simple GET request:web/next/src/components/api-status.tsx
Protected Routes with Authentication
Access protected endpoints with automatic cookie-based authentication:Session Management
Retrieve the current user session:web/next/src/lib/auth/index.ts
Adding New Routes
Types are automatically available
No code generation needed - types flow instantly to the frontend:
web/next/src/components/todos.tsx
Request Methods
Hono RPC supports all HTTP methods:OpenAPI Documentation
ZeroStarter automatically generates interactive API documentation using Scalar. Access it at:/api/docs
The documentation includes:
- All routes with request/response schemas
- Interactive request builder
- Code samples for
hono/client - Authentication support
Adding Documentation to Routes
UsedescribeRoute to add OpenAPI metadata:
api/hono/src/routers/v1.ts
Error Handling
Handle API errors gracefully:Benefits
No Code Generation
Types flow instantly from backend to frontend without any build step or codegen
Autocomplete Everything
Your IDE suggests routes, parameters, and response shapes as you type
Catch Errors Early
Breaking changes in the API are caught at compile time, not runtime
Refactor with Confidence
Rename a route or change a response? TypeScript tells you everywhere it’s used
Next Steps
API Routes
Explore available API endpoints
Authentication
Learn about protected routes
TanStack Query
Master data fetching patterns
Hono Documentation
Deep dive into Hono RPC