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": false,
"logo": "/icon.svg",
"nav": [
{
"text": "Home",
"link": "/"
},
{
"text": "Guide",
"link": "/getting-started"
},
{
"text": "API",
"link": "/api-reference"
}
],
"sidebar": [
{
"text": "Guide",
"items": [
{
"text": "Getting Started",
"link": "/getting-started"
},
{
"text": "Project Templates",
"link": "/templates"
},
{
"text": "Core Concepts",
"link": "/concepts"
},
{
"text": "Build Configurations",
"link": "/build-configurations"
},
{
"text": "Import Tool",
"link": "/import-tool"
},
{
"text": "Configuration",
"link": "/configuration"
}
]
},
{
"text": "Reference",
"items": [
{
"text": "API Reference",
"link": "/api-reference"
},
{
"text": "Testing with xUnit",
"link": "/testing"
}
]
}
],
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/outfox/2dog"
},
{
"icon": "discord",
"link": "https://discord.gg/GAXdbZCNGT"
},
{
"icon": "nuget",
"link": "https://www.nuget.org/packages/twodog/"
}
],
"footer": {
"message": "<a href=\"https://github.com/outfox/2dog?tab=MIT-1-ov-file#readme\">2dog</a> is released under the MIT License.",
"copyright": "Copyright © 2025 <a href=\"https://github.com/outfox/2dog/graphs/contributors\">its contributors</a>"
}
}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.