Appearance
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": "/logo.png", "search": { "provider": "local" }, "nav": [ { "text": "[[b64:5Li76aG1]]", "link": "/" }, { "text": "[[b64:MjAyNeW5tOacuuWcuuaOqOiNkA==]]", "items": [ { "text": "[[b64:6auY56uv5py65Zy6]]", "link": "/blog/2025rec/best/naixi" }, { "text": "[[b64:5bmz5Lu35py65Zy6]]", "link": "/blog/2025rec/better/jieyun" } ] } ], "sidebar": [ { "text": "[[b64:5oCl5pWR55+l6K+G]]", "collapsed": true, "items": [ { "text": "[[b64:6L+Z5Lqb5oCl5pWR55+l6K+G5pS26JeP5aW977yM5YWz6ZSu5pe25Yi76IO95pWR5ZG977yB]]", "link": "/blog/急救/这些急救知识收藏好,关键时刻能救命!" } ] }, { "text": "[[b64:MjAyNeW5tOacuuWcuuaOqOiNkA==]]", "collapsed": true, "items": [ { "text": "[[b64:6auY56uv5py65Zy6]]", "collapsed": true, "items": [ { "text": "Nexitally", "link": "/blog/2025rec/best/naixi" }, { "text": "AmyTelecom", "link": "/blog/2025rec/best/AmyTelecom" }, { "text": "ImmTelecom", "link": "/blog/2025rec/best/ImmTelecom" }, { "text": "Kuromis", "link": "/blog/2025rec/best/Kuromis" } ] }, { "text": "[[b64:5bmz5Lu35aW955So5py65Zy6]]", "collapsed": false, "items": [ { "text": "[[b64:5p2w6Zuy]]", "link": "/blog/2025rec/better/jieyun" } ] }, { "text": "[[b64:5YWN6LS55py65Zy6]]", "collapsed": false, "items": [ { "text": "[[b64:5YWN6LS56K6i6ZiF]]", "link": "/blog/2025rec/free/mianfeidingyue" } ] } ] } ], "footer": { "message": "<a href=\"/使用条款\">使用条款</a> | <a href=\"/联系我们\">联系我们</a>", "copyright": "Copyright © 2025 [[b64:5YiG5Lqr54Ot54ix]]. All Rights Reserved." } }
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.