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:
1<script setup>
2import { useData } from 'vitepress'
3
4const { theme, page, frontmatter } = useData()
5</script>
6
7## Results
8
9### Theme Data
10<pre>{{ theme }}</pre>
11
12### Page Data
13<pre>{{ page }}</pre>
14
15### Page Frontmatter
16<pre>{{ frontmatter }}</pre>
More
Check out the documentation for the full list of runtime APIs.