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

{
  "search": {
    "provider": "local"
  },
  "logo": {
    "src": "/favicon.ico",
    "alt": "SI Logo"
  },
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Ecosystem",
      "items": [
        {
          "text": "Feature 1",
          "link": "/"
        },
        {
          "text": "Feature 2",
          "link": "/"
        },
        {
          "text": "Feature 3",
          "link": "/"
        },
        {
          "text": "Feature 4",
          "link": "/"
        },
        {
          "text": "Feature 5",
          "link": "/"
        }
      ]
    }
  ],
  "sidebar": [
    {
      "text": "Get Started",
      "link": "/get-started",
      "items": [
        {
          "text": "About Me",
          "link": "/about"
        },
        {
          "text": "My Social Links",
          "link": "/social-links"
        },
        {
          "text": "Blog",
          "link": "/blog"
        }
      ]
    },
    {
      "text": "Resources",
      "collapsed": false,
      "link": "/resources",
      "items": [
        {
          "text": "Privacy",
          "link": "/resource-privacy"
        },
        {
          "text": "AI",
          "link": "/resource-ai"
        },
        {
          "text": "Otaku / Streaming / Music",
          "link": "/resource-entertainment"
        },
        {
          "text": "Gaming",
          "link": "/resource-gaming"
        },
        {
          "text": "Education",
          "link": "/resource-education"
        },
        {
          "text": "Download / Torrenting",
          "link": "/resource-downloads"
        },
        {
          "text": "Android",
          "link": "/resource-android"
        },
        {
          "text": "Miscellaneous",
          "link": "/resource-miscellaneous"
        }
      ]
    },
    {
      "text": "Tools",
      "collapsed": false,
      "link": "/tools",
      "items": [
        {
          "text": "System / File Tools",
          "link": "/tool-system"
        },
        {
          "text": "Internet / Social Tools",
          "link": "/tool-internet"
        },
        {
          "text": "Text / Educational Tools",
          "link": "/tool-text"
        },
        {
          "text": "Gaming Tools",
          "link": "/tool-gaming"
        },
        {
          "text": "Media Tools",
          "link": "/tool-media"
        },
        {
          "text": "Developer Tools",
          "link": "/tool-developer"
        }
      ]
    },
    {
      "text": "Miscellaneous",
      "collapsed": false,
      "items": [
        {
          "text": "Storage",
          "link": "/resource-privacy"
        },
        {
          "text": "Vault",
          "link": "/vault"
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "x",
      "link": "https://x.com/@supreme_muhit"
    },
    {
      "icon": "github",
      "link": "https://github.com/suprememuhit"
    }
  ],
  "footer": {
    "message": "Made with ❤️ using <a href=\"https://vitepress.dev\" target=\"_blank\">VitePress</a><br/>\n         This site does not host any files.",
    "copyright": "© 2025 Supreme Index"
  }
}

Page Data

{
  "title": "Runtime API Examples",
  "description": "",
  "frontmatter": {
    "outline": "deep"
  },
  "headers": [
    {
      "level": 2,
      "title": "Results",
      "slug": "results",
      "link": "#results",
      "children": [
        {
          "level": 3,
          "title": "Theme Data",
          "slug": "theme-data",
          "link": "#theme-data",
          "children": []
        },
        {
          "level": 3,
          "title": "Page Data",
          "slug": "page-data",
          "link": "#page-data",
          "children": []
        },
        {
          "level": 3,
          "title": "Page Frontmatter",
          "slug": "page-frontmatter",
          "link": "#page-frontmatter",
          "children": []
        }
      ]
    },
    {
      "level": 2,
      "title": "More",
      "slug": "more",
      "link": "#more",
      "children": []
    }
  ],
  "relativePath": "api-examples copy.md",
  "filePath": "api-examples copy.md"
}

Page Frontmatter

{
  "outline": "deep"
}

More

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

Made with ❤️ using VitePress
This site does not host any files.