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

{
  "siteTitle": "Newsroom",
  "logo": "/theme/logo.svg",
  "nav": [
    {
      "text": "Press Releases",
      "link": "/"
    },
    {
      "text": "Feature Stories",
      "link": "/blog/graphic-design-history"
    },
    {
      "text": "Archive",
      "link": "/blog/markdown-examples"
    },
    {
      "text": "Admin",
      "link": "/admin/"
    }
  ],
  "sidebar": {
    "/blog/": [
      {
        "text": "2026",
        "items": [
          {
            "text": "Graphic Design History",
            "link": "/blog/graphic-design-history"
          },
          {
            "text": "Apple Vision Pro Updates",
            "link": "/blog/api-examples"
          }
        ]
      },
      {
        "text": "Archive",
        "items": [
          {
            "text": "Markdown Examples",
            "link": "/blog/markdown-examples"
          }
        ]
      }
    ]
  },
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/vuejs/vitepress"
    }
  ],
  "footer": {
    "message": "Copyright © 2026 Apple Inc. All rights reserved.",
    "copyright": "Privacy Policy | Terms of Use | Sales and Refunds | Legal | Site Map"
  }
}

Page Data

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

Page Frontmatter

{
  "outline": "deep"
}

More

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

Copyright © 2026 Apple Inc. All rights reserved.