/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-onauthsuccess-c-con-f0f9bc15689b-onauthsuccess-c-context-username-string-void-promise-s0295-c0000.md
onAuthSuccess: `(c: Context, username: string) => void | Promise ` -...
onAuthSuccess: (c: Context, username: string) = void | Promise Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/...
onAuthSuccess: (c: Context, username: string) => void | Promise
Source evidence: /Sources/raw/honojshono/honojshono.md Canonical citation: https://hono.dev/llms-full.txt#onauthsuccess-c-context-username-string-void-promise
Summary
A callback function invoked after successful authentication. This allows you to set context variables or perform side effects without re-parsing the Authorization header. ```ts app.use( '/auth/*', basicAuth({ username: 'hono', password:...
Content
A callback function invoked after successful authentication. This allows you to set context variables or perform side effects without re-parsing the Authorization header.
app.use(
'/auth/*',
basicAuth({
username: 'hono',
password: 'acoolproject',
onAuthSuccess: (c, username) => {
c.set('username', username)
},
})
)
app.get('/auth/page', (c) => {
const username = c.get('username')
return c.text(`Hello, ${username}!`)
})