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>
<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": "/img/fndx-logo2.png", "nav": [ { "text": "🎁 Black Friday 2024 Deals for Mac Apps", "link": "/blackfriday2024-macapps", "activeMatch": "^/" }, { "text": "⌨️ 20 Keyboard-First Apps", "link": "/keyboardfirstapps", "activeMatch": "^/" }, { "text": "Share Your Favorite Products", "link": "/howtoshareaproduct" } ], "sidebar": [ { "text": "Recommended Apps", "items": [ { "text": "CleanClip - macOS clipboard manager", "link": "/cleanclipbasedonmaccy" } ] }, { "text": "Best App Lists", "items": [ { "text": "⌨️ 20 Keyboard-First Apps", "link": "/keyboardfirstapps" } ] }, { "text": "Seasonal Deals Lists", "items": [ { "text": "🎁 Christmas & New Year 2023 Deals List", "link": "/christmasnewyear2023" }, { "text": "🎁 Black Friday 2023 Deals", "link": "/blackfriday2023" }, { "text": "🎁 Black Friday 2024 Deals", "link": "/blackfriday2024" }, { "text": "🎁 Black Friday 2024 Deals for Mac Apps", "link": "/blackfriday2024-macapps" } ] } ], "socialLinks": [ { "icon": "twitter", "link": "https://twitter.com/s1ntone" } ], "footer": { "message": "\n Made by <a href=\"https://fndx.app\" target=\"_blank\">FNDX.app</a>", "copyright": "<a href=\"https://fndx.app\" target=\"_blank\">Find Your Next AWESOME App🔥</a>" } }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep" }, "headers": [], "relativePath": "api-examples.md", "filePath": "api-examples.md", "lastUpdated": 1732077513000 }
Page Frontmatter
{ "outline": "deep" }
More
Check out the documentation for the full list of runtime APIs.