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": {
"light": "/logo-dark.svg",
"dark": "/logo-light.svg"
},
"nav": [
{
"text": "Home",
"link": "/"
},
{
"text": "Javascript Book",
"link": "https://leanpub.com/javascriptstarter-ahandsonguide"
}
],
"sidebar": {
"/general/": [
{
"text": "General Patterns",
"items": [
{
"text": "Iterator pattern",
"link": "/general/iterator-pattern/index.html"
},
{
"text": "Command pattern",
"link": "/general/command-pattern/index.html"
},
{
"text": "Chain of Responsibility",
"link": "/general/chain-of-responsibility/index.html"
},
{
"text": "Composite Pattern",
"link": "/general/composite-pattern/index.html"
},
{
"text": "Proxy Pattern",
"link": "/general/proxy-pattern/index.html"
},
{
"text": "Facade Pattern",
"link": "/general/facade-pattern/index.html"
},
{
"text": "Decorator Pattern",
"link": "/general/decorator-pattern/index.html"
},
{
"text": "Bridge Pattern",
"link": "/general/bridge-pattern/index.html"
},
{
"text": "Adapter Pattern",
"link": "/general/adapter-pattern/index.html"
},
{
"text": "Prototype Pattern",
"link": "/general/prototype-pattern/index.html"
},
{
"text": "Builder Pattern",
"link": "/general/builder-pattern/index.html"
},
{
"text": "Abstract Factory",
"link": "/general/abstract-factory/index.html"
},
{
"text": "Factory, Service Registry",
"link": "/general/factory-service-registry-patterns/index.html"
},
{
"text": "Singleton, Testing ...",
"link": "/general/singleton-testing-concurrency-clusters/index.html"
},
{
"text": "Solid",
"link": "/general/solid/index.html"
},
{
"text": "Functional Composition",
"link": "/general/functioncomposition/index.html"
}
]
}
],
"/devops/": [
{
"text": "DevOps",
"items": [
{
"text": "auto deploy mern app",
"link": "/devops/auto-deploy-mern-app/index.html"
},
{
"text": "Day 9/30: Terraform modules",
"link": "/devops/day-9-terraform-modules/index.html"
}
]
}
],
"/spendgauge-engineering/": [
{
"text": "from code - production (spendgauge)",
"items": [
{
"text": "product thinking from spendgauge",
"link": "/spendgauge-engineering/product-thinking/index.html"
},
{
"text": "schema constraints for spendgauge",
"link": "/spendgauge-engineering/schema-constraints/index.html"
},
{
"text": "tradeoffs I took for spendgauge",
"link": "/spendgauge-engineering/database-tradeoffs/index.html"
}
]
}
],
"/vue-challenge/": [
{
"text": "10 Day Vue Js Challenge",
"items": [
{
"text": "Day 1 ",
"link": "/vue-challenge/day-one/index.html"
},
{
"text": "Day 2 ",
"link": "/vue-challenge/day-two/index.html"
},
{
"text": "Day 3 ",
"link": "/vue-challenge/day-three/index.html"
}
]
}
],
"/javascript-tips/": [
{
"text": "Javascript tips",
"items": [
{
"text": "digging the event loop ",
"link": "/javascript-tips/event-loop/index.html"
},
{
"text": "async/await orchestration ",
"link": "/javascript-tips/async-await/index.html"
},
{
"text": "Set beyond - duplicates ",
"link": "/javascript-tips/set/index.html"
},
{
"text": "static methods stateless ",
"link": "/javascript-tips/static-methods/index.html"
},
{
"text": "Cleaner conditional logic ",
"link": "/javascript-tips/cleaner-conditional-logic/index.html"
},
{
"text": "Working with JS objects ",
"link": "/javascript-tips/objects/index.html"
},
{
"text": "isNaN vs Number.isNaN",
"link": "/javascript-tips/isnan/index.html"
},
{
"text": "Date UTC vs Local Time",
"link": "/javascript-tips/date/index.html"
}
]
}
]
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/KoomeKelvin"
},
{
"icon": "x",
"link": "https://x.com/koomekelvink"
},
{
"icon": "linkedin",
"link": "https://linkedin.com/in/koome-kelvin"
}
],
"footer": {
"message": "Enjoy every byte.",
"copyright": "Copyright © 2025-present Koome Kelvin"
}
}Page Data
{
"title": "Runtime API Examples",
"description": "",
"frontmatter": {
"outline": "deep"
},
"headers": [],
"relativePath": "api-examples.md",
"filePath": "api-examples.md"
}Page Frontmatter
{
"outline": "deep"
}More
Check out the documentation for the full list of runtime APIs.