Skip to content

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.svg",
    "dark": "logo-white.svg",
    "alt": "kuloud logo"
  },
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Blog",
      "link": "/blog/"
    },
    {
      "text": "Presentations",
      "link": "/presentations/"
    },
    {
      "text": "Docs",
      "items": [
        {
          "text": "amap_map",
          "link": "/projects/amap_map"
        }
      ]
    }
  ],
  "sidebar": {
    "/api-examples.md/": {
      "text": "Api Examples",
      "link": "/api-examples"
    },
    "/blog/": {
      "text": "Blog",
      "collapsible": true,
      "items": [
        {
          "text": "Git Branch Clean",
          "link": "/blog/2025-03-31-git-branch-clean"
        },
        {
          "text": "Overview",
          "link": "/blog/"
        },
        {
          "text": "Solana",
          "link": "/blog/2025-03-31-solana"
        },
        {
          "text": "Vercel Environments",
          "link": "/blog/2025-03-27-vercel-environments"
        }
      ]
    },
    "/markdown-examples.md/": {
      "text": "Markdown Examples",
      "link": "/markdown-examples"
    },
    "/presentations/": {
      "text": "Presentations",
      "collapsible": true,
      "items": [
        {
          "text": "Auto",
          "link": "/presentations/auto"
        },
        {
          "text": "Overview",
          "link": "/presentations/"
        }
      ]
    },
    "/projects/": {
      "text": "Projects",
      "collapsible": true,
      "items": [
        {
          "text": "Auto",
          "collapsible": true,
          "items": [
            {
              "text": "Getting Start",
              "collapsible": true,
              "items": [
                {
                  "text": "Getting started",
                  "link": "/projects/auto/getting-start/introduction"
                }
              ]
            },
            {
              "text": "Workflow",
              "collapsible": true,
              "items": [
                {
                  "text": "Overview",
                  "link": "/projects/auto/workflow/"
                }
              ]
            }
          ]
        }
      ]
    }
  },
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/kuloud"
    }
  ],
  "footer": {
    "copyright": "Copyright © 2025 kuloud"
  },
  "search": {
    "provider": "local"
  }
}

Page Data

{
  "title": "Runtime API Examples",
  "description": "",
  "frontmatter": {
    "outline": "deep"
  },
  "headers": [],
  "relativePath": "api-examples.md",
  "filePath": "api-examples.md",
  "lastUpdated": 1742634875000
}

Page Frontmatter

{
  "outline": "deep"
}

More

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

Last updated: