Skip to content

Runtime API Examples123

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

{
  "i18nRouting": true,
  "logo": "/logo-mini.png",
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/krismileji"
    },
    {
      "icon": "gitee",
      "link": "https://gitee.com/krismileJ"
    }
  ],
  "footer": {
    "message": "Released under the Apache-2.0 License",
    "copyright": "Copyright © 2021-2025 krismile"
  }
}

Page Data

{
  "title": "Runtime API Examples123",
  "description": "",
  "frontmatter": {
    "outline": "deep"
  },
  "headers": [],
  "relativePath": "en/api-examples.md",
  "filePath": "en/api-examples.md",
  "lastUpdated": 1764065844000
}

Page Frontmatter

{
  "outline": "deep"
}

More

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

Last updated:

Released under the Apache-2.0 License