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

{
  "logo": "/images/logo.png",
  "search": {
    "provider": "local"
  },
  "outlineTitle": "目录",
  "outline": [
    2,
    6
  ],
  "nav": [
    {
      "text": "首页",
      "link": "/"
    },
    {
      "text": "AI沉浸式学习",
      "items": [
        {
          "text": "AI学习资料",
          "link": "markdown-examples"
        },
        {
          "text": "AI实战项目",
          "link": "/AI_docs"
        },
        {
          "text": "AI视频教程",
          "link": "/videos/"
        }
      ]
    },
    {
      "text": "示例",
      "link": "www.googo.com"
    }
  ],
  "sidebar": {
    "/pythond_docs": [
      {
        "text": "Nginx-1.24 安装部署",
        "link": "/python_docs/Nginx-1.24 安装部署.md"
      },
      {
        "text": "docs_image",
        "collapsible": true,
        "items": []
      },
      {
        "text": "java证书问题处理",
        "link": "/python_docs/java证书问题处理.md"
      },
      {
        "text": "linux常用命令",
        "link": "/python_docs/linux常用命令.md"
      }
    ],
    "/AI_docs": [
      {
        "text": "用户同步方案",
        "link": "/AI_docs/用户同步方案.md"
      }
    ]
  },
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/vuejs/vitepress"
    },
    {
      "icon": "gitee",
      "link": "htts://github.com"
    }
  ],
  "footer": {
    "copyright": "Copyright@ 2026.01.06 create site"
  }
}

Page Data

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

Page Frontmatter

{
  "outline": "deep"
}

More

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