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
{
"nav": [
{
"text": "$ home",
"link": "/"
},
{
"text": "$ docs",
"link": "/markdown-examples"
},
{
"text": "$ api",
"link": "/api-examples"
}
],
"sidebar": [
{
"text": "📁 Documentation",
"items": [
{
"text": "> Markdown Examples",
"link": "/markdown-examples"
},
{
"text": "> Runtime API",
"link": "/api-examples"
}
]
},
{
"text": "📁 Tutorials",
"items": [
{
"text": "> Getting Started",
"link": "/getting-started"
}
]
}
],
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/Lo7ong/"
}
],
"footer": {
"message": "System Status: ✓ Online | Built with VitePress",
"copyright": "Copyright © 2025 Lo7ong"
},
"search": {
"provider": "local"
},
"editLink": {
"pattern": "https://github.com/Lo7ong/lo7ong.github.io/edit/main/docs/:path",
"text": "Edit this page on GitHub"
},
"lastUpdated": {
"text": "Last commit",
"formatOptions": {
"dateStyle": "short",
"timeStyle": "short"
}
},
"outline": {
"level": [
2,
3
],
"label": "$ Contents"
},
"docFooter": {
"prev": "Previous",
"next": "Next"
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md",
"lastUpdated": 1770788306000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.