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
{
"nav": [
{
"text": "Home",
"link": "/"
},
{
"text": "Projects",
"items": [
{
"text": "BeWidgets",
"link": "/bewidgets/",
"activeMatch": "/bewidgets/"
}
]
},
{
"text": "Rapidoc",
"items": [
{
"text": "Util Api",
"link": "/rapidoc/util-api",
"activeMatch": "/rapidoc/util-api"
},
{
"text": "BeWidgets Micro Store Api",
"link": "/rapidoc/bewidgets-micro-store-api",
"activeMatch": "/rapidoc/bewidgets-micro-store-api"
}
]
}
],
"sidebar": {
"/": [
{
"text": "Examples",
"items": [
{
"text": "Markdown Examples",
"link": "/markdown-examples"
},
{
"text": "Runtime API Examples",
"link": "/api-examples"
}
]
}
],
"/accounts/": [
{
"text": "Accounts",
"link": "/accounts/",
"items": []
}
],
"/bewidgets/": [
{
"text": "BeWidgets",
"link": "/bewidgets/",
"collapsed": false,
"items": [
{
"text": "Widget",
"link": "/bewidgets/widget"
},
{
"text": "Layouts",
"link": "/bewidgets/layouts"
},
{
"text": "Store",
"link": "/bewidgets/store"
},
{
"text": "Advanced",
"collapsed": true,
"items": [
{
"text": "Sideloading a Widget Package",
"link": "/bewidgets/advanced/sideloading-widget-package"
}
]
}
]
},
{
"text": "Widget Developer",
"link": "/bewidgets/developer",
"collapsed": false,
"items": [
{
"text": "Getting Started",
"link": "/bewidgets/developer/getting-started"
},
{
"text": "Creating a Custom Widget",
"link": "/bewidgets/developer/create-custom-widget"
},
{
"text": "Debugging",
"link": "/bewidgets/developer/debugging"
},
{
"text": "Packaging",
"link": "/bewidgets/developer/packaging"
},
{
"text": "Publishing",
"link": "/bewidgets/developer/publishing"
},
{
"text": "Continue Development",
"link": "/bewidgets/developer/continue-development/continue-development",
"collapsed": false,
"items": [
{
"text": "BeWidgets.Widget",
"link": "/bewidgets/developer/continue-development/bewidgets-widget"
},
{
"text": "Widget Icon",
"link": "/bewidgets/developer/continue-development/widget-icon"
},
{
"text": "Widget Metadata",
"link": "/bewidgets/developer/continue-development/widget-metadata"
},
{
"text": "Widget App",
"link": "/bewidgets/developer/continue-development/widget-app"
},
{
"text": "WidgetPage Events",
"link": "/bewidgets/developer/continue-development/widgetpage-events"
},
{
"text": "Widget Menu",
"link": "/bewidgets/developer/continue-development/widget-menu"
},
{
"text": "Models",
"link": "/bewidgets/developer/continue-development/models"
},
{
"text": "Custom Settings",
"link": "/bewidgets/developer/continue-development/custom-settings"
},
{
"text": "Settings Controls",
"link": "/bewidgets/developer/continue-development/settings-controls"
},
{
"text": "Other Controls",
"link": "/bewidgets/developer/continue-development/other-controls"
},
{
"text": "Other Pages",
"link": "/bewidgets/developer/continue-development/other-pages"
}
]
},
{
"text": "Tutorials",
"link": "/bewidgets/developer/tutorials/tutorials",
"collapsed": true,
"items": [
{
"text": "Simple Time Widget",
"link": "/bewidgets/developer/tutorials/simple-time-widget"
}
]
}
]
}
]
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/bexcool/docs"
},
{
"icon": "discord",
"link": "https://linkify.cz/discord"
}
],
"editLink": {
"pattern": "https://github.com/bexcool/docs/blob/main/:path"
},
"footer": {
"message": "Released under CC-BY-4.0",
"copyright": "© BeXCool 2025"
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md",
"lastUpdated": 1761210124000
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.