For AI agents: the complete documentation index is available at https://rspress.rs/llms.txt, the full documentation bundle is available at https://rspress.rs/llms-full.txt, and this page is available as Markdown at https://rspress.rs/ui/hooks/use-frontmatter.md.
close
  • English
  • useFrontmatter

    useFrontmatter returns the frontmatter of the current page in a convenient object.

    • Type: () => { frontmatter: FrontMatterMeta }

    Example: render a custom badge when the page is marked as beta in frontmatter.

    import { useFrontmatter } from '@rspress/core/runtime';
    
    export default function BetaBadge() {
      const { frontmatter } = useFrontmatter();
      return frontmatter.beta ? <span>Beta</span> : null;
    }

    Combine with usePage when you also need other page metadata (title, route, toc, etc.).