/Knowledge/sources/honojs__hono/llms-full/request-id-middleware-usage-set-request-id--156a9f395a66.md
Request ID Middleware: Usage > Set Request ID - hono-docs
Request ID Middleware: Usage Set Request ID Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt set reques...
Request ID Middleware: Usage > Set Request ID
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#set-request-id
Summary
You set a custom request ID in the header (default: X-Request-Id), the middleware will use that value instead of generating a new one: ```ts const app = new Hono() app.use('*', requestId()) app.get('/', (c) => { return c.text(`${c.get(...
Content
You set a custom request ID in the header (default: X-Request-Id), the middleware will use that value instead of generating a new one:
const app = new Hono()
app.use('*', requestId())
app.get('/', (c) => {
return c.text(`${c.get('requestId')}`)
})
const res = await app.request('/', {
headers: {
'X-Request-Id': 'your-custom-id',
},
})
console.log(await res.text()) // your-custom-id
If you want to disable this feature, set headerName option to an empty string.
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#set-request-id",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Request ID Middleware > Usage > Set Request ID",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 340,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Request ID Middleware: Usage > Set Request ID",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}