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

{
  "footer": {
    "copyright": "Copyright © 2026 CloseX"
  },
  "nav": [
    {
      "text": "More",
      "items": [
        {
          "text": "Privacy Policy",
          "link": "/privacy"
        },
        {
          "text": "Release Notes",
          "link": "/release-note"
        },
        {
          "text": "Blog",
          "link": "https://blog.closex.org"
        },
        {
          "text": "CloseX",
          "link": "https://closex.org"
        },
        {
          "text": "Contact Us",
          "link": "mailto:[email protected]"
        }
      ]
    }
  ],
  "search": {
    "provider": "local",
    "options": {
      "locales": {
        "zh": {
          "translations": {
            "button": {
              "buttonText": "搜索文档",
              "buttonAriaLabel": "搜索文档"
            },
            "modal": {
              "noResultsText": "无法找到相关结果",
              "resetButtonTitle": "清除查询条件",
              "footer": {
                "selectText": "选择",
                "navigateText": "切换",
                "closeText": "关闭"
              }
            }
          }
        },
        "ja": {
          "translations": {
            "button": {
              "buttonText": "文書の検索",
              "buttonAriaLabel": "文書の検索"
            },
            "modal": {
              "noResultsText": "関連する結果が見つかりませんでした",
              "resetButtonTitle": "クエリ条件をクリアする",
              "footer": {
                "selectText": "選ぶ",
                "navigateText": "スイッチ",
                "closeText": "閉鎖"
              }
            }
          }
        }
      }
    }
  },
  "logo": "/img/logo.webp",
  "sidebar": {
    "/launchnext/": [
      {
        "text": "LaunchNext",
        "items": [
          {
            "text": "Overview",
            "link": "/launchnext/"
          },
          {
            "text": "Getting Started",
            "link": "/launchnext/getting-started"
          },
          {
            "text": "Settings",
            "link": "/launchnext/settings/"
          },
          {
            "text": "CLI and TUI",
            "link": "/launchnext/cli-and-tui"
          },
          {
            "text": "Updates and Troubleshooting",
            "link": "/launchnext/updates-and-troubleshooting"
          }
        ]
      },
      {
        "text": "Settings Tabs",
        "items": [
          {
            "text": "General",
            "link": "/launchnext/settings/general"
          },
          {
            "text": "Appearance",
            "link": "/launchnext/settings/appearance"
          },
          {
            "text": "Performance",
            "link": "/launchnext/settings/performance"
          },
          {
            "text": "Titles",
            "link": "/launchnext/settings/titles"
          },
          {
            "text": "App Sources",
            "link": "/launchnext/settings/app-sources"
          },
          {
            "text": "Hidden Apps",
            "link": "/launchnext/settings/hidden-apps"
          },
          {
            "text": "Uninstall",
            "link": "/launchnext/settings/uninstall"
          },
          {
            "text": "Shortcut & Gesture",
            "link": "/launchnext/settings/shortcuts"
          },
          {
            "text": "Backup",
            "link": "/launchnext/settings/backup"
          },
          {
            "text": "Development",
            "link": "/launchnext/settings/development"
          },
          {
            "text": "Sound",
            "link": "/launchnext/settings/sound"
          },
          {
            "text": "Game Controller",
            "link": "/launchnext/settings/game-controller"
          }
        ]
      }
    ],
    "/": [
      {
        "text": "Projects",
        "collapsed": true,
        "items": [
          {
            "text": "LaunchNext",
            "link": "/launchnext/"
          },
          {
            "text": "TranslateNext",
            "link": "/translatenext/"
          },
          {
            "text": "WhisperNext",
            "link": "/whispernext/"
          },
          {
            "text": "SeeNext",
            "link": "/seenext/"
          }
        ]
      },
      {
        "text": "LaunchNext Settings",
        "collapsed": true,
        "items": [
          {
            "text": "Titles",
            "link": "/launchnext/settings/titles"
          },
          {
            "text": "Hidden Apps",
            "link": "/launchnext/settings/hidden-apps"
          },
          {
            "text": "Uninstall",
            "link": "/launchnext/settings/uninstall"
          },
          {
            "text": "Shortcut & Gesture",
            "link": "/launchnext/settings/shortcuts"
          },
          {
            "text": "Sound",
            "link": "/launchnext/settings/sound"
          },
          {
            "text": "Game Controller",
            "link": "/launchnext/settings/game-controller"
          }
        ]
      },
      {
        "text": "LaunchNext Advanced",
        "collapsed": true,
        "items": [
          {
            "text": "Overview",
            "link": "/launchnext/"
          },
          {
            "text": "Settings",
            "link": "/launchnext/settings-guide"
          },
          {
            "text": "Settings Map",
            "link": "/launchnext/settings-overview"
          },
          {
            "text": "Backup and Restore",
            "link": "/launchnext/backup-and-restore"
          },
          {
            "text": "Updates",
            "link": "/launchnext/updates-and-troubleshooting"
          },
          {
            "text": "Development",
            "link": "/launchnext/settings/development"
          }
        ]
      }
    ]
  }
}

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.