/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-using-middleware-77d8645b9889-using-middleware-s0522-c0000.md
Using Middleware - hono-docs
Using Middleware Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt using middleware Summary Middlew...
Using Middleware
Source evidence: /Sources/raw/honojshono/honojshono.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.