/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-using-with-index-pa-3e91eca4747a-using-with-index-parameter-s0736-c0000.md
Using with index parameter - hono-docs
Using with index parameter Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt using with index param...
Using with index parameter
Source evidence: /Sources/raw/honojshono/honojshono.md Canonical citation: https://hono.dev/llms-full.txt#using-with-index-parameter
Summary
You can optionally pass an index parameter to get the base route path at a specific position, similar to Array.prototype.at(). ```ts app.all('/api/*', (c, next) => { return next() }) const subApp = new Hono() subApp.get('/users/:id', (...
Content
You can optionally pass an index parameter to get the base route path at a specific
position, similar to Array.prototype.at().
app.all('/api/*', (c, next) => {
return next()
})
const subApp = new Hono()
subApp.get('/users/:id', (c) => {
console.log(baseRoutePath(c, 0)) // '/' (first matched route)
console.log(baseRoutePath(c, -1)) // '/api' (last matched route)
return c.text('User details')
})
app.route('/api', subApp)