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": "/assets/images/logo_simple_blue_no_y_padding.svg",
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Examples",
      "link": "/markdown-examples"
    }
  ],
  "sidebar": [
    {
      "text": "Overview",
      "link": "/overview"
    },
    {
      "text": "Visas",
      "items": [
        {
          "text": "Overview",
          "link": "/visas/"
        },
        {
          "text": "With no degree?",
          "link": "/visas/with-no-degree"
        },
        {
          "text": "Types of Visas",
          "link": "/visas/types"
        },
        {
          "text": "Permanent Residency (PR)",
          "link": "/visas/pr"
        },
        {
          "text": "Citizenship",
          "link": "/visas/citizenship"
        },
        {
          "text": "Highly Skilled Professional (HSP)",
          "link": "/visas/hsp"
        }
      ]
    },
    {
      "text": "Salaries",
      "items": [
        {
          "text": "Overview",
          "link": "/salaries/"
        },
        {
          "text": "Averages",
          "link": "/salaries/averages"
        },
        {
          "text": "Ranges",
          "link": "/salaries/ranges"
        }
      ]
    },
    {
      "text": "Healthcare & Insurance",
      "link": "/healthcare-insurance"
    },
    {
      "text": "Interviewing + Resumes",
      "items": [
        {
          "text": "Overview",
          "link": "/interviewing-resumes/"
        },
        {
          "text": "DSA/Leetcode?",
          "link": "/interviewing-resumes/dsa-leetcode"
        },
        {
          "text": "Negotiation",
          "link": "/interviewing-resumes/negotiation"
        },
        {
          "text": "Japanese Interviews",
          "link": "/interviewing-resumes/japanese-interviews"
        },
        {
          "text": "Resumes",
          "link": "/interviewing-resumes/resumes"
        }
      ]
    },
    {
      "text": "Companies",
      "items": [
        {
          "text": "Overview",
          "link": "/companies/"
        },
        {
          "text": "Japanese Interviews",
          "link": "/companies/japanese-interviews"
        },
        {
          "text": "Two Worlds",
          "link": "/companies/two-worlds"
        },
        {
          "text": "Huge List of Modern Companies",
          "link": "/companies/huge-list"
        }
      ]
    },
    {
      "text": "Jobs",
      "items": [
        {
          "text": "Overview",
          "link": "/jobs/"
        },
        {
          "text": "Sources",
          "link": "/jobs/sources"
        },
        {
          "text": "Difficulty",
          "link": "/jobs/difficulty"
        },
        {
          "text": "Tips",
          "link": "/jobs/tips"
        },
        {
          "text": "Juniors",
          "link": "/jobs/juniors"
        },
        {
          "text": "Japanese Skills",
          "link": "/jobs/japanese-skills"
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/vuejs/vitepress"
    }
  ],
  "search": {
    "provider": "local"
  }
}

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.