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

{
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Examples",
      "link": "/markdown-examples"
    }
  ],
  "sidebar": [
    {
      "text": "All Documents",
      "items": [
        {
          "text": "Analysis",
          "collapsed": false,
          "items": [
            {
              "text": "01 business domain overview",
              "link": "/analysis/01-business-domain-overview"
            },
            {
              "text": "02 program meeting domain",
              "link": "/analysis/02-program-meeting-domain"
            },
            {
              "text": "03 speaker domain",
              "link": "/analysis/03-speaker-domain"
            },
            {
              "text": "04 attendee registration domain",
              "link": "/analysis/04-attendee-registration-domain"
            },
            {
              "text": "05 budget domain",
              "link": "/analysis/05-budget-domain"
            },
            {
              "text": "06 compliance domain",
              "link": "/analysis/06-compliance-domain"
            },
            {
              "text": "07 user permission domain",
              "link": "/analysis/07-user-permission-domain"
            },
            {
              "text": "08 communication domain",
              "link": "/analysis/08-communication-domain"
            },
            {
              "text": "09 integration domain",
              "link": "/analysis/09-integration-domain"
            },
            {
              "text": "10 reporting domain",
              "link": "/analysis/10-reporting-domain"
            },
            {
              "text": "11 configuration domain",
              "link": "/analysis/11-configuration-domain"
            },
            {
              "text": "12 geographic domain",
              "link": "/analysis/12-geographic-domain"
            },
            {
              "text": "13 content document domain",
              "link": "/analysis/13-content-document-domain"
            },
            {
              "text": "14 survey domain",
              "link": "/analysis/14-survey-domain"
            },
            {
              "text": "15 expense domain",
              "link": "/analysis/15-expense-domain"
            },
            {
              "text": "16 virtual program domain",
              "link": "/analysis/16-virtual-program-domain"
            },
            {
              "text": "Business requirements spec",
              "link": "/analysis/business-requirements-spec"
            },
            {
              "text": "Cross cutting issues",
              "link": "/analysis/cross-cutting-issues"
            }
          ]
        },
        {
          "text": "Api examples",
          "link": "/api-examples"
        },
        {
          "text": "Budget allocation analysis",
          "link": "/budget-allocation-analysis"
        },
        {
          "text": "Markdown examples",
          "link": "/markdown-examples"
        },
        {
          "text": "Meeting lifecycle redesign",
          "link": "/meeting-lifecycle-redesign"
        },
        {
          "text": "Meeting status unification design",
          "link": "/meeting-status-unification-design"
        },
        {
          "text": "Platform redesign v2",
          "link": "/platform-redesign-v2"
        },
        {
          "text": "Platform redesign v2 zh",
          "link": "/platform-redesign-v2-zh"
        },
        {
          "text": "Status system analysis",
          "link": "/status-system-analysis"
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/vuejs/vitepress"
    }
  ]
}

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.