Skip to content

Runtime API Examples

This page demonstrates usage of some of the runtime APIs provided by VitePress.

The main useData() API can be used to access site, theme, and page data for the current page. It works in both .md and .vue files:

md
<script setup>
import { useData } from 'vitepress'

const { theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>

Results

Theme Data

{
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Guides",
      "link": "/guides/introduction"
    }
  ],
  "search": {
    "provider": "local"
  },
  "sidebar": {
    "/guides/": [
      {
        "text": "Linux",
        "collapsed": false,
        "items": [
          {
            "text": "Cheatsheet",
            "link": "/guides/linux/linux-cheatsheet"
          },
          {
            "text": "Install Docker Compose",
            "link": "/guides/linux/install-docker"
          }
        ]
      },
      {
        "text": "macOS",
        "collapsed": true,
        "items": [
          {
            "text": "Version compatibility",
            "collapsed": true,
            "items": [
              {
                "text": "macOS 10.13: High Sierra",
                "link": "/guides/macos/compatibility/macos-10-13"
              },
              {
                "text": "macOS 10.14: Mojave",
                "link": "/guides/macos/compatibility/macos-10-14"
              },
              {
                "text": "macOS 10.15: Catalina",
                "link": "/guides/macos/compatibility/macos-10-15"
              },
              {
                "text": "macOS 11: Big Sur",
                "link": "/guides/macos/compatibility/macos-11"
              },
              {
                "text": "macOS 12: Monterey",
                "link": "/guides/macos/compatibility/macos-12"
              },
              {
                "text": "macOS 13: Ventura",
                "link": "/guides/macos/compatibility/macos-13"
              },
              {
                "text": "macOS 14: Sonoma",
                "link": "/guides/macos/compatibility/macos-14"
              },
              {
                "text": "macOS 15: Sequoia",
                "link": "/guides/macos/compatibility/macos-15"
              }
            ]
          }
        ]
      },
      {
        "text": "Windows",
        "collapsed": true,
        "items": [
          {
            "text": "Bypass Windows 11 internet requirement",
            "link": "/guides/windows/bypass-win11-internet-requirement"
          },
          {
            "text": "Windows 11 on unsupported hardware",
            "link": "/guides/windows/install-win11-unsupported-hardware"
          }
        ]
      },
      {
        "text": "Android",
        "collapsed": true,
        "items": [
          {
            "text": "Installing LineageOS in Xiaomi Mi Smart Clock",
            "link": "/guides/windows/install-lineage-os-mi-smart-clock"
          }
        ]
      }
    ]
  },
  "socialLinks": [
    {
      "icon": "forgejo",
      "link": "https://git.logilynx.be"
    }
  ]
}

Page Data

{
  "title": "Runtime API Examples",
  "description": "",
  "frontmatter": {
    "outline": "deep"
  },
  "headers": [],
  "relativePath": "api-examples.md",
  "filePath": "api-examples.md",
  "lastUpdated": 1737383664000
}

Page Frontmatter

{
  "outline": "deep"
}

More

Check out the documentation for the full list of runtime APIs.

Last updated: