/Knowledge/sources/honojs__hono/llms-full/getting-started-using-middleware--152793db34d0.md
Getting Started: Using Middleware - hono-docs
Getting Started: Using Middleware Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt using middleware Sum...
Getting Started: Using Middleware
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#using-middleware
Summary
Middleware can do the hard work for you. For example, add in Basic Authentication. ```ts import { basicAuth } from 'hono/basic-auth' // ... app.use( '/admin/*', basicAuth({ username: 'admin', password: 'secret', }) ) app.get('/admin', (c...
Content
Middleware can do the hard work for you. For example, add in Basic Authentication.
import { basicAuth } from 'hono/basic-auth'
// ...
app.use(
'/admin/*',
basicAuth({
username: 'admin',
password: 'secret',
})
)
app.get('/admin', (c) => {
return c.text('You are authorized!')
})
There are useful built-in middleware including Bearer and authentication using JWT, CORS and ETag. Hono also provides third-party middleware using external libraries such as GraphQL Server and Firebase Auth. And, you can make your own middleware.
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#using-middleware",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Getting Started > Using Middleware",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 522,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Getting Started: Using Middleware",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}