/Knowledge/sources/honojs__hono/llms-full/route-helper-baseroutepath-using-with-index-parameter--15ccb89b4e19.md
Route Helper: baseRoutePath() > Using with index parameter - hono-docs
Route Helper: baseRoutePath() Using with index parameter Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.t...
Route Helper: baseRoutePath() > Using with index parameter
Source evidence: /Sources/honojs__hono/provenance.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)
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#using-with-index-parameter",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Route Helper > `baseRoutePath()` > Using with index parameter",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 736,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Route Helper: baseRoutePath() > Using with index parameter",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}