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": "Audi Tutorials", "lang": "zh-CN", "docFooter": { "prev": "上一篇", "next": "下一篇" }, "darkModeSwitchLabel": "外观", "returnToTopLabel": "返回顶部", "sidebarMenuLabel": "菜单", "outline": { "label": "页面导航" }, "nav": [ { "text": "首页", "link": "/" }, { "text": "ODIS 安装", "link": "/install/odis" }, { "text": "ODIS 编程", "link": "/docs/introduce" }, { "text": "免责声明", "link": "/disclaimer" }, { "text": "Joiner 小组件", "link": "https://joiner.i95.me" }, { "text": "奥迪固件升级", "link": "https://joiner.i95.me/upgrade.html" }, { "text": "MIB 固件验证", "link": "https://mib.i95.me" } ], "sidebar": { "/install/": [ { "text": "ODIS 安装", "items": [ { "text": "安装", "link": "/install/odis" }, { "text": "下载", "link": "/install/resource" } ] } ], "/docs/": [ { "text": "ODIS 编程", "items": [ { "text": "编程准备提示", "link": "/docs/introduce" }, { "text": "Android 盒子屏蔽", "link": "/docs/audi-android-box-blocking" }, { "text": "Audi 44xx 修复无线 CarPlay", "link": "/docs/audi-fixed-wireless-carplay" }, { "text": "大众 MQB 空调 22 度", "link": "/docs/vw-mbq-22-degree-jump-temp-slider" }, { "text": "无线 CarPlay / Android Auto", "link": "/docs/audi-wireless-cp-aa" }, { "text": "开启客户端 WIFI 功能", "link": "/docs/audi-open-wifi" } ] } ] }, "socialLinks": [ { "icon": "bloglovin", "link": "https://iiong.com" } ], "footer": { "copyright": "Copyright © 2025. <a href=\"https://iiong.com\" target=\"_blank\" rel=\"nofollow noopener\">淮城一只猫</a> - <a href=\"http://beian.miit.gov.cn\" target=\"_blank\" rel=\"nofollow noopener\">苏ICP备15050739号</a>" } }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep" }, "headers": [], "relativePath": "api-examples.md", "filePath": "api-examples.md", "lastUpdated": 1753621734000 }
Page Frontmatter
{ "outline": "deep" }
More
Check out the documentation for the full list of runtime APIs.