useDocsNavigation

Read the docs navigation tree that the shell has already loaded. The header section bar, sidebar and docs pages all take their navigation from here, so custom components reuse the same data without querying the collection again.

useDocsNavigation() returns the navigation tree that useDocsShell provides in app.vue, already loaded and transformed for the current locale.

Usage

app/components/SectionList.vue
<script setup lang="ts">
const navigation = useDocsNavigation()
</script>

<template>
  <ul>
    <li v-for="section in navigation" :key="section.path">
      <NuxtLink :to="section.path">
        {{ section.title }}
      </NuxtLink>
    </li>
  </ul>
</template>

Signature

function useDocsNavigation(): Ref<ContentNavigationItem[] | undefined>

Return Value

NameTypeDescription
(return value)Ref<ContentNavigationItem[] | undefined>Top-level sections under the docs root; each children holds the section's pages, and the category and description frontmatter fields are kept on each node

Notes

  • Call it inside the component tree of app.vue or error.vue. Outside the shell (for example a custom app.vue that does not call useDocsShell) you get a ref whose value is undefined.
  • The injection key is the string 'navigation'. v2 code that calls inject('navigation') directly still works; new code should use this function.
  • To group by category or build breadcrumbs, pass the result to useNavigation.

Changelog

No recent changes
Copyright © 2024 - 2026