/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-createmiddleware-091de13a996f-createmiddleware-s0660-c0000.md
`createMiddleware()` - hono-docs
createMiddleware() Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt createmiddleware Summary creat...
createMiddleware()
Source evidence: /Sources/raw/honojshono/honojshono.md Canonical citation: https://hono.dev/llms-full.txt#createmiddleware
Summary
createMiddleware() is shortcut of factory.createMiddleware(). This function will create your custom middleware. ```ts const messageMiddleware = createMiddleware(async (c, next) => { await next() c.res.headers.set('X-Message', 'Good m...
Content
createMiddleware() is shortcut of factory.createMiddleware().
This function will create your custom middleware.
const messageMiddleware = createMiddleware(async (c, next) => {
await next()
c.res.headers.set('X-Message', 'Good morning!')
})Tip: If you want to get an argument like message, you can create it as a function like the following.
const messageMiddleware = (message: string) => {
return createMiddleware(async (c, next) => {
await next()
c.res.headers.set('X-Message', message)
})
}
app.use(messageMiddleware('Good evening!'))