> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/honojs/hono/llms.txt
> Use this file to discover all available pages before exploring further.

# Route Helper

> Utilities for accessing route information

The Route Helper provides utilities for accessing information about matched routes and base paths.

## Import

```typescript theme={null}
import { matchedRoutes, routePath, baseRoutePath, basePath } from 'hono/route'
```

## Functions

### matchedRoutes()

Get all matched routes for the current request.

```typescript theme={null}
function matchedRoutes(c: Context, index?: number): RouterRoute | RouterRoute[] | undefined
```

<ParamField path="c" type="Context" required>
  The context object
</ParamField>

<ParamField path="index" type="number">
  Optional index to get a specific route (supports negative indices)
</ParamField>

<ResponseField name="return" type="RouterRoute | RouterRoute[] | undefined">
  The matched route(s) or undefined if index is out of range
</ResponseField>

**Example**

```typescript theme={null}
import { matchedRoutes } from 'hono/route'

app.get('/api/:id', (c) => {
  const routes = matchedRoutes(c)
  console.log(routes) // All matched routes
  
  const last = matchedRoutes(c, -1)
  console.log(last?.path) // '/api/:id'
  
  return c.text('OK')
})
```

### routePath()

Get the matched route path.

```typescript theme={null}
function routePath(c: Context): string | undefined
```

<ParamField path="c" type="Context" required>
  The context object
</ParamField>

<ResponseField name="return" type="string | undefined">
  The route path (e.g., '/api/:id')
</ResponseField>

### baseRoutePath()

Get the base route path from the routes array.

```typescript theme={null}
function baseRoutePath(c: Context): string | undefined
```

<ParamField path="c" type="Context" required>
  The context object
</ParamField>

<ResponseField name="return" type="string | undefined">
  The base route path
</ResponseField>

### basePath()

Get the base path from the request.

```typescript theme={null}
function basePath(c: Context): string
```

<ParamField path="c" type="Context" required>
  The context object
</ParamField>

<ResponseField name="return" type="string">
  The base path (e.g., '/api')
</ResponseField>

## Types

```typescript theme={null}
type RouterRoute = [
  handler: H,
  method: string,
  path: string
]
```
