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": "/de/"
},
{
"text": "Examples",
"link": "/de/markdown-examples"
},
{
"text": "Other",
"items": [
{
"text": "Test",
"link": "/de/test"
},
{
"text": "Team",
"link": "/de/team"
}
]
}
],
"sidebar": [
{
"text": "Examples",
"items": [
{
"text": "Markdown Examples",
"link": "/de/markdown-examples"
},
{
"text": "Runtime API Examples",
"link": "/de/api-examples"
}
]
}
],
"footer": {
"message": "Released under the MIT License.",
"copyright": "Copyright © 2019-present Evan You"
},
"logo": {
"light": "/logo-light.svg",
"dark": "/logo-dark.svg",
"alt": "Logo"
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/vuejs/vitepress"
},
{
"icon": "discord",
"link": "https://discord.gg/"
},
{
"icon": {
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\"> <path d=\"M0 0h24v24H0z\" fill=\"none\" /> <path fill=\"currentColor\" d=\"M11 9h2V7h-2m1 13c-4.41 0-8-3.59-8-8s3.59-8 8-8s8 3.59 8 8s-3.59 8-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2m-1 15h2v-6h-2z\" /> </svg>"
},
"link": "/en/about"
}
]
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "de/api-examples.md",
"filePath": "de/api-examples.md"
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.