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
{
"search": {
"provider": "local"
},
"sidebar": [
{
"text": "User Guide",
"collapsed": false,
"items": [
{
"text": "Overview",
"link": "/userguide/index.md"
}
]
},
{
"text": "Developers Guides",
"collapsed": true,
"items": [
{
"text": "SysEx Implementation",
"link": "/developers/midiimplementation.md"
},
{
"text": "File Transfer SysEx API",
"link": "/developers/filetransfer.md"
},
{
"text": "Lua Extension",
"link": "/developers/luaext.md"
},
{
"text": "Preset JSON",
"link": "/developers/presetformat.md"
},
{
"text": "Performance JSON",
"link": "/developers/performanceformat.md"
},
{
"text": "Devices Override JSON",
"link": "/developers/devicesformat.md"
},
{
"text": "Config JSON",
"link": "/developers/confformat.md"
}
]
},
{
"text": "Troubleshooting",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/troubleshooting/index.md"
}
]
}
],
"socialLinks": [
{
"icon": "youtube",
"link": "https://www.youtube.com/@electraone"
},
{
"icon": "github",
"link": "https://github.com/vuejs/vitepress"
}
],
"outline": {
"level": [
2,
3
]
},
"footer": {
"message": "Made with ❤️ in the Czech Republic · © 2019 - 2025 Electra One"
}
}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.