/Knowledge/sources/honojs__hono/llms-full/basic-auth-middleware-recipes-defining-multiple-users--c1df464b03f2.md
Basic Auth Middleware: Recipes > Defining Multiple Users - hono-docs
Basic Auth Middleware: Recipes Defining Multiple Users Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt...
Basic Auth Middleware: Recipes > Defining Multiple Users
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#defining-multiple-users
Summary
This middleware also allows you to pass arbitrary parameters containing objects defining more username and password pairs. ```ts app.use( '/auth/*', basicAuth( { username: 'hono', password: 'acoolproject', // Define other params in t...
Content
This middleware also allows you to pass arbitrary parameters containing objects defining more username and password pairs.
app.use(
'/auth/*',
basicAuth(
{
username: 'hono',
password: 'acoolproject',
// Define other params in the first object
realm: 'www.example.com',
},
{
username: 'hono-admin',
password: 'super-secure',
// Cannot redefine other params here
},
{
username: 'hono-user-1',
password: 'a-secret',
// Or here
}
)
)
Or less hardcoded:
import { users } from '../config/users'
app.use(
'/auth/*',
basicAuth(
{
realm: 'www.example.com',
...users[0],
},
...users.slice(1)
)
)
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#defining-multiple-users",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Basic Auth Middleware > Recipes > Defining Multiple Users",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 299,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Basic Auth Middleware: Recipes > Defining Multiple Users",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}