Skip to content

Checking authentication status...

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": "/logo.svg",
  "nav": [
    {
      "link": "/",
      "text": "Home"
    },
    {
      "link": "/markdown-examples",
      "text": "Examples"
    },
    {
      "link": "/frontend-web",
      "text": "Frontend Web"
    }
  ],
  "sidebar": [
    {
      "text": "Examples",
      "items": [
        {
          "link": "/markdown-examples",
          "text": "Markdown Examples"
        },
        {
          "link": "/api-examples",
          "text": "Runtime API Examples"
        }
      ]
    },
    {
      "text": "Frontend Web",
      "base": "/frontend-web",
      "collapsed": true,
      "items": [
        {
          "link": "/",
          "text": "Overview",
          "docFooterText": "Frontend Web - Overview"
        },
        {
          "link": "/data-layer",
          "text": "Data Layer",
          "docFooterText": "Frontend Web - Data Layer"
        },
        {
          "link": "/domain-layer",
          "text": "Domain Layer",
          "docFooterText": "Frontend Web - Domain Layer"
        },
        {
          "link": "/ui-layer",
          "text": "UI Layer",
          "docFooterText": "Frontend Web - UI Layer"
        },
        {
          "link": "/error-handling",
          "text": "Error Handling",
          "docFooterText": "Frontend Web - Error Handling"
        },
        {
          "link": "/react",
          "text": "React",
          "docFooterText": "Frontend Web - React"
        },
        {
          "link": "/next",
          "text": "Next",
          "docFooterText": "Frontend Web - Next"
        },
        {
          "link": "/vue",
          "text": "Vue",
          "docFooterText": "Frontend Web - Vue"
        },
        {
          "link": "/nuxt",
          "text": "Nuxt",
          "docFooterText": "Frontend Web - Nuxt"
        }
      ]
    }
  ],
  "footer": {
    "copyright": "Copyright © 2026 <a href=\"https://nbs.co.id?utm_medium=website&utm_source=nbs.pages.dev&utm_content=footer\" target=\"_blank\">nbs.co.id</a>"
  },
  "search": {
    "provider": "local"
  }
}

Page Data

{
  "title": "Runtime API Examples",
  "description": "",
  "frontmatter": {
    "layout": "doc",
    "outline": "deep",
    "auth": true
  },
  "headers": [],
  "relativePath": "api-examples.md",
  "filePath": "api-examples.md"
}

Page Frontmatter

{
  "layout": "doc",
  "outline": "deep",
  "auth": true
}

More

Check out the documentation for the full list of runtime APIs.