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": { "src": "/favicon.svg", "style": "height: 36px", "alt": "ALT Gnome Logo" }, "socialLinks": [ { "icon": "github", "link": "https://github.com/alt-gnome/alt-gnome.ru" } ], "nav": [ { "text": "О нас", "link": "/" }, { "text": "База знаний", "link": "https://alt-gnome.wiki/" }, { "text": "Команды", "link": "/markdown-examples" } ], "footer": { "message": "© 2025 ALT Gnome" } }
Page Data
{ "title": "Runtime API Examples", "description": "Страница «Runtime API Examples». Последнее обновление: Invalid Date", "frontmatter": { "outline": "deep", "head": [ [ "meta", { "name": "og:title", "content": "Runtime API Examples | ALT Gnome" } ], [ "meta", { "name": "og:type", "content": "website" } ], [ "meta", { "name": "og:locale", "content": "ru-RU" } ], [ "meta", { "name": "og:url", "content": "https://alt-gnome.wiki/api-examples.html" } ], [ "meta", { "name": "og:site_name", "content": "ALT Gnome" } ], [ "meta", { "name": "og:image", "content": "https://alt-gnome.ru/og-alt-wiki.jpg" } ], [ "meta", { "name": "twitter:card", "content": "summary_large_image" } ], [ "meta", { "name": "twitter:image", "content": "https://alt-gnome.ru/og-alt-wiki.jpg" } ], [ "link", { "rel": "canonical", "href": "https://alt-gnome.ru/api-examples.html" } ] ] }, "headers": [], "relativePath": "api-examples.md", "filePath": "api-examples.md" }
Page Frontmatter
{ "outline": "deep", "head": [ [ "meta", { "name": "og:title", "content": "Runtime API Examples | ALT Gnome" } ], [ "meta", { "name": "og:type", "content": "website" } ], [ "meta", { "name": "og:locale", "content": "ru-RU" } ], [ "meta", { "name": "og:url", "content": "https://alt-gnome.wiki/api-examples.html" } ], [ "meta", { "name": "og:site_name", "content": "ALT Gnome" } ], [ "meta", { "name": "og:image", "content": "https://alt-gnome.ru/og-alt-wiki.jpg" } ], [ "meta", { "name": "twitter:card", "content": "summary_large_image" } ], [ "meta", { "name": "twitter:image", "content": "https://alt-gnome.ru/og-alt-wiki.jpg" } ], [ "link", { "rel": "canonical", "href": "https://alt-gnome.ru/api-examples.html" } ] ] }
More
Check out the documentation for the full list of runtime APIs.