Skip to main content
Hono includes a comprehensive collection of built-in middleware for common web application needs. All middleware is available via the hono package.

Authentication & Authorization

Middleware for securing your application and verifying user identity.

Basic Auth

HTTP Basic authentication with username and password

Bearer Auth

Bearer token authentication for API access

JWT

JSON Web Token authentication and verification

JWK

Verify JWT tokens using JSON Web Keys

Security

Middleware to enhance application security and protect against common vulnerabilities.

CORS

Cross-Origin Resource Sharing configuration

CSRF

Cross-Site Request Forgery protection

Secure Headers

Set security-related HTTP headers

IP Restriction

Allow or deny requests based on IP address

Performance & Optimization

Middleware to improve application performance and reduce bandwidth.

Compress

Response compression with gzip or deflate

Cache

Cache responses for improved performance

ETag

Generate ETags for cache validation

Timing

Add Server-Timing headers for performance monitoring

Request Processing

Middleware for handling and validating incoming requests.

Body Limit

Limit the size of request bodies

Method Override

Override HTTP method for legacy clients

Timeout

Set request timeout limits

Trailing Slash

Enforce or remove trailing slashes in URLs

Response Formatting

Middleware for formatting and customizing responses.

Pretty JSON

Format JSON responses with indentation

Powered By

Add custom X-Powered-By header

Utilities & Helpers

Middleware for logging, internationalization, and other utilities.

Logger

Log incoming requests and responses

Request ID

Generate unique IDs for each request

Language

Detect and set user language preferences

Context Storage

Store context data across async operations

Static Files & Views

Middleware for serving static files and rendering views.

Serve Static

Serve static files from a directory

JSX Renderer

Render JSX components as responses

Advanced

Advanced middleware for special use cases.

Combine

Combine multiple middleware into one

Usage Examples

Common Setup

A typical Hono application might use several middleware together:

Production-Ready Setup

For production applications, consider this middleware stack:
For detailed API documentation of each middleware including all options and advanced usage, see the API Reference section.