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.svg",
"editLink": {
"pattern": "https://github.com/icancodefyi/basecompose/edit/master/basecompose-docs/docs/:path",
"text": "Edit this page on GitHub"
},
"nav": [
{
"text": "Home",
"link": "/"
},
{
"text": "Getting Started",
"link": "/getting-started"
},
{
"text": "Features",
"link": "/features"
},
{
"text": "Architecture",
"link": "/architecture"
},
{
"text": "Contributing",
"link": "/contributing"
},
{
"text": "FAQ",
"link": "/faq"
},
{
"text": "License",
"link": "/license"
}
],
"sidebar": [
{
"text": "Getting Started",
"items": [
{
"text": "Introduction",
"link": "/introduction"
},
{
"text": "Live Demo & Quick Start",
"link": "/quickstart"
},
{
"text": "Getting Started",
"link": "/getting-started"
}
]
},
{
"text": "Core Concepts",
"items": [
{
"text": "Features Overview",
"link": "/features"
},
{
"text": "Project Structure",
"link": "/project-structure"
},
{
"text": "Architecture & Generation Flow",
"link": "/architecture"
},
{
"text": "Supported Technologies & Stacks",
"link": "/technologies"
}
]
},
{
"text": "How To Use",
"items": [
{
"text": "Usage Guide",
"link": "/usage-guide"
},
{
"text": "Templates & Addons",
"link": "/templates"
},
{
"text": "Environment Variables",
"link": "/env-vars"
}
]
},
{
"text": "Development",
"items": [
{
"text": "Development Setup",
"link": "/dev-setup"
},
{
"text": "Contribution Guide",
"link": "/contributing"
}
]
},
{
"text": "Help & Community",
"items": [
{
"text": "FAQ & Troubleshooting",
"link": "/faq"
},
{
"text": "Security & Code of Conduct",
"link": "/security"
}
]
},
{
"text": "Meta",
"items": [
{
"text": "Release Notes & Changelog",
"link": "/changelog"
},
{
"text": "License",
"link": "/license"
}
]
}
],
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/icancodefyi/basecompose"
}
]
}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.