1. Home
  2. ChevronRightHooks
  3. ChevronRightuseRoutes

useRoutes

Access metadata and config mappings for all compiled documentation pages.

The useRoutes hook gives access to metadata for all generated page paths, along with localized version configurations.


ImportLink

import { useRoutes } from 'boltdocs/client'

Return ValuesLink

PropertyTypeDescription
allRoutesRouteMeta[]Listing of all compiled documentation page routing records.
currentRouteRouteMeta | undefinedMetadata representing the active route route.
currentLocalestring | undefinedThe active language locale identifier.
currentVersionstring | undefinedThe active configuration version tag.

RouteMeta InterfaceLink

interface RouteMeta {
  path: string              // URL path route (e.g. '/docs/guides')
  title: string             // Page title from frontmatter or heading
  description?: string      // Page description from frontmatter
  headings: Heading[]       // Array of MDX headers in the file
  frontmatter: any          // Raw frontmatter metadata map
  sidebarPosition?: number  // Custom sorting index for left side navigation
}

Example: Displaying Sub-Pages IndexLink

import { useRoutes } from 'boltdocs/client'

export function GuideList() {
  const { allRoutes, currentRoute } = useRoutes()

  // Filter routes that are children of the current path
  const subPages = allRoutes.filter(
    (route) =>
      route.path.startsWith(currentRoute?.path || '') &&
      route.path !== currentRoute?.path
  )

  return (
    <div className="my-6">
      <h3 className="text-lg font-bold mb-2">In this section:</h3>
      <ul className="list-disc pl-5">
        {subPages.map((route) => (
          <li key={route.path}>
            <a href={route.path} className="text-blue-500 hover:underline">
              {route.title}
            </a>
            {route.description && <p className="text-xs text-gray-500">{route.description}</p>}
          </li>
        ))}
      </ul>
    </div>
  )
}
Last updated on July 27, 2026

Was this page helpful?