Skip to main content
Hono’s middleware system is flexible and can integrate with third-party packages. This guide covers how to use external middleware and lists popular options.

Middleware Compatibility

Hono middleware follows a simple signature:
Any function matching this signature can be used as Hono middleware, whether it comes from a third-party package or is written inline.

Using Third-Party Middleware

Direct Compatible Middleware

If a package exports Hono-compatible middleware, you can use it directly:

Wrapping Express/Connect Middleware

While Hono and Express have different middleware signatures, you can create adapters:
Note that Express middleware may not always work perfectly with Hono due to different runtime environments and API differences. Test thoroughly when adapting middleware.

Authentication & Authorization

@hono/auth-js

Auth.js (NextAuth.js) integration for Hono

@hono/oauth-providers

OAuth provider integrations

Validation & Parsing

@hono/zod-validator

Validate requests using Zod schemas

@hono/valibot-validator

Validate requests using Valibot

Observability & Monitoring

@hono/sentry

Sentry error tracking integration

@hono/prometheus

Prometheus metrics collection

Database & ORM

@hono/prisma

Prisma ORM integration

@hono/graphql-server

GraphQL server middleware

Template Engines

@hono/react-renderer

Server-side React rendering

@hono/ejs-renderer

EJS template rendering

Utilities

@hono/swagger

Swagger/OpenAPI documentation

@hono/firebase-auth

Firebase Authentication middleware

Creating Middleware Packages

If you’re creating a middleware package for others to use:

Package Structure

Package.json Setup

Documentation Example

Usage

Options

  • option1 (required): Description
  • option2 (optional): Description

Finding Middleware

Discover Hono middleware packages:

Official Middleware

Browse the official Hono middleware repository

npm Search

Search npm for packages tagged with hono-middleware

Best Practices

Before using third-party middleware, verify:
  • It’s compatible with your Hono version
  • It works with your runtime (Cloudflare Workers, Deno, Bun, Node.js)
  • It’s actively maintained
  • It has good documentation
Always test third-party middleware in a development environment before deploying to production:
Wrap third-party middleware in error handlers:
Regularly update middleware packages to get:
  • Security fixes
  • Performance improvements
  • New features
  • Bug fixes

Contributing

If you create a useful middleware, consider:
  1. Open sourcing it - Share it with the community on GitHub
  2. Publishing to npm - Make it easy for others to install
  3. Tagging properly - Use the hono-middleware keyword
  4. Documenting well - Include examples and API documentation
  5. Adding tests - Ensure it works correctly
  6. Submitting to awesome-hono - Get it listed in community resources

Built-in Middleware

Explore Hono’s built-in middleware

Custom Middleware

Learn to create your own middleware