Hono
Comprehensive Hono cheat sheet covering routing, middleware, context, validation, RPC client, streaming, and deployment across Cloudflare Workers, Bun, Deno, and Node.js.
Table of Contents
Getting Started
Create a New Project
Initialize a Hono project with create-hono CLI
Basic Hello World
Create your first Hono application
Routing
HTTP Methods & Paths
Define routes for different HTTP methods
Path Parameters
Extract dynamic values from URLs
Route Groups & Basepath
Organize routes with grouping and base paths
Context & Request
Request Data
Access query params, headers, body, and more
Response Methods
Different ways to send responses
Context Variables
Store and retrieve values in request context
Middleware
Creating Middleware
Define and use custom middleware
Built-in Middleware
Common middleware included with Hono
Authentication Middleware
Basic Auth, Bearer Auth, and JWT middleware
Validation
Zod Validation
Type-safe validation with Zod schemas
Built-in Validator
Use Hono's built-in validator without external deps
RPC Client
Type-Safe Client
Create a type-safe API client from your Hono app
Client Usage
Use the type-safe RPC client
Streaming & SSE
Server-Sent Events
Stream real-time updates to clients
WebSockets
Real-time bidirectional communication
Error Handling
HTTPException & Error Handlers
Handle errors gracefully in your app
Deployment
Cloudflare Workers
Deploy to Cloudflare Workers edge network
Bun, Deno & Node.js
Deploy to other JavaScript runtimes
Testing
Testing with app.request()
Test your Hono app without starting a server