Prompt Buddy logoPrompt Buddy

hono · Hono Docs

Middleware

Teaches how to implement, order, and extend Hono middleware, including using the createMiddleware factory for type-safe context extension and modifying responses after the handler executes.

Import to Prompt Buddy

Derived skill

Files assembled from official documentation

Viewing SKILL.md

Middleware

Teaches how to implement, order, and extend Hono middleware, including using the createMiddleware factory for type-safe context extension and modifying responses after the handler executes.

When To Use

Use when you need to intercept requests, modify responses, extend the Hono context with custom variables, or implement reusable logic across multiple routes.

Reference Files

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/middleware-workflow-guide.mdA guide explaining the definition, execution order, built-in options, and custom implementation of middleware in Hono.Questions about a guide explaining the definition, execution order, built-in options, and custom implementation of middleware in Hono.
examples/middleware-hono-middleware-typescript-usage-examples.tsTypeScript code demonstrating how to apply different middleware patterns to routes and methods in a Hono application.Exact payloads, commands, or snippets shown in TypeScript code demonstrating how to apply different middleware patterns to routes and methods in a Hono application.
examples/middleware-hono-middleware-typescript.tsA TypeScript code example demonstrating how to implement and apply middleware within a Hono application.Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement and apply middleware within a Hono application.
examples/middleware-hono-middleware-logger-cors-basicauth-typescript.tsA TypeScript example demonstrating the sequential application of logger, cors, and basicAuth middleware in a Hono application.Exact payloads, commands, or snippets shown in A TypeScript example demonstrating the sequential application of logger, cors, and basicAuth middleware in a Hono app...
examples/middleware-hono-middleware-async-execution-order.tsA TypeScript example demonstrating how multiple asynchronous middleware functions execute in sequence using the next function in Hono.Exact payloads, commands, or snippets shown in A TypeScript example demonstrating how multiple asynchronous middleware functions execute in sequence using the next...
examples/middleware-hono-middleware-execution-order.textA text representation demonstrating the sequential execution flow of multiple Hono middleware layers.Exact payloads, commands, or snippets shown in A text representation demonstrating the sequential execution flow of multiple Hono middleware layers.
examples/middleware-hono-middleware-typescript-usage-examples-2.tsA TypeScript code example demonstrating how to apply built-in middleware like logger, poweredBy, and basicAuth to a Hono application instance.Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to apply built-in middleware like logger, poweredBy, and basicAuth to a H...
examples/middleware-hono-middleware-websocket-upgrade-typescript.tsA TypeScript example demonstrating how to use the upgradeWebSocket middleware in a Hono application.Exact payloads, commands, or snippets shown in A TypeScript example demonstrating how to use the upgradeWebSocket middleware in a Hono application.
examples/middleware-hono-middleware-custom-logger-and-header-typescript.tsA TypeScript example demonstrating how to implement custom middleware for logging requests and adding custom response headers in a Hono application.Exact payloads, commands, or snippets shown in A TypeScript example demonstrating how to implement custom middleware for logging requests and adding custom response...
examples/middleware-hono-middleware-factory-create-typescript.tsA TypeScript example demonstrating how to use the createMiddleware factory function to build custom middleware in Hono.Exact payloads, commands, or snippets shown in A TypeScript example demonstrating how to use the createMiddleware factory function to build custom middleware in Hono.
examples/middleware-hono-middleware-create-middleware-typescript.tsA TypeScript code example demonstrating how to use the createMiddleware function to define custom middleware in Hono.Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to use the createMiddleware function to define custom middleware in Hono.
examples/middleware-hono-middleware-create-middleware-typescript-2.tsA TypeScript example demonstrating how to use the createMiddleware function to intercept and modify a response in Hono.Exact payloads, commands, or snippets shown in A TypeScript example demonstrating how to use the createMiddleware function to intercept and modify a response in Hono.
examples/middleware-hono-middleware-cors-typescript.tsA TypeScript code example demonstrating how to implement CORS middleware in a Hono application.Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement CORS middleware in a Hono application.
examples/middleware-hono-middleware-factory-create-typescript-2.tsA TypeScript example demonstrating how to use the createMiddleware factory function to define and apply custom middleware in a Hono application.Exact payloads, commands, or snippets shown in A TypeScript example demonstrating how to use the createMiddleware factory function to define and apply custom middle...
examples/middleware-hono-middleware-factory-create-typescript-3.tsA TypeScript example demonstrating how to use the createMiddleware factory to define custom middleware with typed context variables in Hono.Exact payloads, commands, or snippets shown in A TypeScript example demonstrating how to use the createMiddleware factory to define custom middleware with typed con...

What This Skill Covers

  • Middleware works before/after the endpoint Handler. We can get the Request before dispatching or manipulate the Response after dispatching.
  • Main sections: Definition of Middleware, Execution order, Built-in Middleware, Custom Middleware, Modify the Response After Next.

Workflow

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. Do not add behavior or configuration that is not present in the attached source files.

Canonical source: https://hono.dev/docs/guides/middleware