hono-middleware
Hono middleware patterns - creation, composition, built-in middleware, and execution order for web applications
By bobmatnyc · 390 installs
npx skills add bobmatnyc/claude-mpm-skills --skill hono-middleware
Source repository · Upstream listing
Hono Middleware Patterns
Overview
Hono provides a powerful middleware system with an "onion" execution model. Middleware processes requests before handlers and responses after handlers, enabling cross cutting concerns like authentication, logging, and CORS.
Key Features :
Onion style execution order
Type safe middleware creation with createMiddleware
25+ built in middleware
Context variable passing between middleware
Async/await support throughout
When to Use This Skill
Use Hono middleware when:
Adding authentication/authorization
Implementing CORS for cross origin requests
Adding request logging or timing
Compressing responses
Rate limiting API endpoints
Validating requests before handlers
Middleware Basics
Inline Middleware
Execution Order (Onion Model)
Creating Reusable Middleware
Context Variables
Passing Data Between Middleware
Built in Middleware
CORS
Bearer Auth
Basic Auth
JWT Auth
Logger
Pretty JSON
Compress
ETag
Cache
Secure Headers
CSRF Protection
Timeout
Request ID
Advanced Patterns
Conditional Middleware
Middleware Composition
Modifying Responses
Error Handling in Middleware
Rate Limiting
Middleware Order Best Practices
Quick Reference
Built in Middleware
Middleware Import Purpose
cors hono/cors Cross origin requests
bearerAuth hono/bearer auth Bearer token auth
basicAuth hono/basic auth HTTP Basic auth
jwt hono/jwt JWT verification
logger hono/logger Request logging
prettyJSON hono/pretty json JSON formatting
compress hono/compress Response compression
etag hono/etag ETag headers
cache hono/cache Response caching
secureHeaders hono/secure headers Security headers
csrf hono/csrf CSRF protection
timeout hono/timeout Request timeout
requestId hono/request id Request ID header
Third Party Middleware
Related Skills
hono core Framework fundamentals
hono validation Request validation with Zod
hono cloudflare Cloudflare specific middleware
Version : Hono 4.x
Last Updated : January 2025
License : MIT