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, isDark } = useData()
</script>
## Results
### Theme Data
<pre>{{ theme }}</pre>
### Page Data
<pre>{{ page }}</pre>
### Page Frontmatter
<pre>{{ frontmatter }}</pre>
### isDark
<pre>{{ isDark }}</pre>
Results
Theme Data
{ "logo": "/rainbow_space.png", "externalLinkIcon": true, "editLink": { "text": "Edit", "pattern": "https://github.com/holyspiritomb/autpunk.space/edit/main/:path" }, "nav": [ { "text": "Home", "link": "/" }, { "text": "Projects", "link": "/projects" }, { "text": "Writing", "link": "/thought-fossils" }, { "text": "Links", "link": "/other-people" }, { "text": "Demo", "link": "/vitepress-default/components" } ], "search": { "provider": "local", "options": { "miniSearch": { "options": {}, "searchOptions": {} } } }, "sidebar": [ { "text": "Home", "link": "/" }, { "text": "Projects ", "link": "/projects/index.md", "items": [ { "text": "Forks", "items": [ { "text": "Available Reads", "link": "/projects/forks/available-reads" }, { "text": "PyXyzzy", "link": "/projects/forks/pyxyzzy" }, { "text": "Libby Userscript", "link": "/projects/forks/libby-userscript" } ], "collapsed": true } ], "collapsed": true }, { "text": "Thought Fossils", "link": "/thought-fossils/index.md", "items": [ { "text": "Extreme workaholic mindsets", "link": "/thought-fossils/bro-what-traumas" }, { "text": "On \"Victim Mentality\"", "link": "/thought-fossils/victim-mentality" } ], "collapsed": true }, { "text": "Unsorted Fragments", "link": "/unsorted-fragments/index.md" }, { "text": "Links", "link": "/other-people/index.md", "items": [ { "text": "Friends", "link": "/other-people/friends" }, { "text": "Music recommendations", "link": "/other-people/music" }, { "text": "Podcast recommendations", "link": "/other-people/podcasts" } ], "collapsed": true } ], "socialLinks": [ { "icon": "vitepress", "ariaLabel": "source repository for this site", "link": "https://github.com/holyspiritomb/autpunk.space" }, { "icon": "github", "ariaLabel": "my github profile", "link": "https://github.com/holyspiritomb" }, { "icon": "gitlab", "ariaLabel": "my gitlab profile", "link": "https://gitlab.com/holyspiritomb" }, { "icon": "archlinux", "ariaLabel": "my arch user repository packages", "link": "https://aur.archlinux.org/packages?SeB=m&K=spiritomb" }, { "icon": "bluesky", "ariaLabel": "my bluesky", "link": "https://bsky.app/profile/spiritomb.bsky.social" } ], "lastUpdated": { "text": "Last updated", "formatOptions": { "dateStyle": "long", "timeStyle": "medium" } }, "footer": { "message": "Released under a <a href=\"https://creativecommons.org/licenses/by-nc-sa/4.0/\">CC BY-NC-SA 4.0</a> license", "copyright": "Copyright © 2025-present Hezekiah Michael" } }
Page Data
{ "title": "Runtime API Examples", "description": "", "frontmatter": { "outline": "deep" }, "headers": [], "relativePath": "vitepress-default/api-examples.md", "filePath": "vitepress-default/api-examples.md", "lastUpdated": 1740334105000 }
Page Frontmatter
{ "outline": "deep" }
isDark
true
More
Check out the documentation for the full list of runtime APIs.