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": "Quick Start",
      "link": "/quick-start"
    },
    {
      "text": "Download",
      "link": "https://chrome.google.com/webstore/detail/chejfhdknideagdnddjpgamkchefjhoi"
    }
  ],
  "sidebar": [
    {
      "text": "Introduction",
      "link": "/introduction"
    },
    {
      "text": "Installation",
      "link": "/installation"
    },
    {
      "text": "Quick Start",
      "link": "/quick-start"
    },
    {
      "text": "Extension Limitations (Unimplementable Features)",
      "link": "/limitations"
    },
    {
      "text": "About Premium",
      "link": "/about-premium"
    },
    {
      "text": "Tabs",
      "collapsed": false,
      "items": [
        {
          "text": "Supported Menus",
          "link": "/tabs/menus"
        },
        {
          "text": "Drag & Drop and Multi-Select",
          "link": "/tabs/drag-drop-multi-select"
        },
        {
          "text": "Tree View",
          "link": "/tabs/tree-view"
        },
        {
          "text": "Closing Tabs",
          "link": "/tabs/closing-tabs"
        },
        {
          "text": "Refreshing Tabs",
          "link": "/tabs/refreshing-tabs"
        },
        {
          "text": "Suspending Tabs",
          "link": "/tabs/suspending-tabs"
        },
        {
          "text": "Renaming Tabs",
          "link": "/tabs/renaming-tabs"
        },
        {
          "text": "Tab Lens (Page Monitoring)",
          "link": "/tabs/tab-lens"
        },
        {
          "text": "Copying Tab Information",
          "link": "/tabs/copying-tabs"
        },
        {
          "text": "Sorting Tabs",
          "link": "/tabs/sorting-tabs"
        },
        {
          "text": "Pinning Tabs",
          "link": "/tabs/pinning-tabs"
        },
        {
          "text": "Keep Tabs Active",
          "link": "/tabs/keep-tabs-active"
        },
        {
          "text": "Scheduled Refresh/Suspend/Close Tabs",
          "link": "/tabs/scheduled-tasks"
        },
        {
          "text": "Tab History",
          "link": "/tabs/tab-history"
        },
        {
          "text": "Window Tab Display",
          "link": "/tabs/window-tab-display"
        },
        {
          "text": "Tab Display Customization",
          "link": "/tabs/tab-display-customization"
        },
        {
          "text": "Recent Tabs",
          "link": "/tabs/recent-tabs"
        },
        {
          "text": "Return to Last Accessed Tab After Closing",
          "link": "/tabs/tab-close-behavior"
        },
        {
          "text": "Drag and Drop Hover Menu",
          "link": "/tabs/drag-hover-menu"
        },
        {
          "text": "Auto Scroll to Active Tab",
          "link": "/tabs/auto-scroll"
        },
        {
          "text": "Clear Tab Data",
          "link": "/tabs/clear-tab-data"
        },
        {
          "text": "Tab Control Buttons",
          "link": "/tabs/tab-control-buttons"
        },
        {
          "text": "Open new tab next to active tab",
          "link": "/tabs/open-new-tab-next-to-active-tab"
        }
      ]
    },
    {
      "text": "Groups",
      "collapsed": false,
      "items": [
        {
          "text": "Group Context Menu",
          "link": "/groups/context-menu"
        },
        {
          "text": "Create Groups",
          "link": "/groups/creation"
        },
        {
          "text": "Group by Site",
          "link": "/groups/group-by-site"
        },
        {
          "text": "AI Smart Grouping",
          "link": "/groups/ai-grouping"
        },
        {
          "text": "Auto Activate Tab Grouping",
          "link": "/groups/auto-activate-grouping"
        },
        {
          "text": "Tab Group Collapse Behavior",
          "link": "/groups/collapse-behavior"
        },
        {
          "text": "Group Display Settings",
          "link": "/groups/display-settings"
        }
      ]
    },
    {
      "text": "Tab Windows",
      "collapsed": false,
      "items": [
        {
          "text": "Display Current Window/All Windows Tabs",
          "link": "/tab-windows/display-scope"
        },
        {
          "text": "Show Window Title",
          "link": "/tab-windows/window-title"
        },
        {
          "text": "Window Configuration Presets",
          "link": "/tab-windows/window-presets"
        },
        {
          "text": "Automatic Window Grouping",
          "link": "/tab-windows/auto-grouping"
        }
      ]
    },
    {
      "text": "Quick Access",
      "collapsed": false,
      "items": [
        {
          "text": "Overview",
          "link": "/quick-access/overview"
        },
        {
          "text": "Usage",
          "link": "/quick-access/usage"
        },
        {
          "text": "Settings",
          "link": "/quick-access/settings"
        },
        {
          "text": "Batch Add from History",
          "link": "/quick-access/batch-add-from-history"
        }
      ]
    },
    {
      "text": "Tab Snapshots",
      "collapsed": false,
      "items": [
        {
          "text": "What are Tab Snapshots?",
          "link": "/snapshots/index"
        },
        {
          "text": "Create Snapshots Manually",
          "link": "/snapshots/creation"
        },
        {
          "text": "Auto Snapshots (Background)",
          "link": "/snapshots/auto-snapshots"
        },
        {
          "text": "View & Restore (Side Panel)",
          "link": "/snapshots/sidepanel-view"
        },
        {
          "text": "How to Restore Snapshots",
          "link": "/snapshots/restore"
        },
        {
          "text": "Manage All Snapshots",
          "link": "/snapshots/management"
        },
        {
          "text": "Edit Snapshots",
          "link": "/snapshots/edit"
        },
        {
          "text": "Import (Session Buddy/TSM/Toby)",
          "link": "/snapshots/import"
        },
        {
          "text": "Sync Snapshots (Premium)",
          "link": "/snapshots/sync"
        }
      ]
    },
    {
      "text": "Auto Suspend/Close Tabs",
      "collapsed": false,
      "items": [
        {
          "text": "Overview",
          "link": "/auto-suspend/overview"
        },
        {
          "text": "Auto Tab Discard (Suspend)",
          "link": "/auto-suspend/discard"
        },
        {
          "text": "Auto Close Tabs",
          "link": "/auto-suspend/close"
        },
        {
          "text": "FAQ",
          "link": "/auto-suspend/faq"
        }
      ]
    },
    {
      "text": "Bookmarks",
      "collapsed": false,
      "items": [
        {
          "text": "View Bookmarks",
          "link": "/bookmarks/view-bookmarks"
        },
        {
          "text": "Add Bookmarks",
          "link": "/bookmarks/add-bookmarks"
        },
        {
          "text": "Supported Context Menu Items",
          "link": "/bookmarks/context-menu"
        },
        {
          "text": "Bookmark Settings",
          "link": "/bookmarks/settings"
        },
        {
          "text": "Use Bookmark Folder Names as Group Names",
          "link": "/bookmarks/folder-as-group-name"
        },
        {
          "text": "Check Duplicate Bookmarks",
          "link": "/bookmarks/check-duplicates"
        },
        {
          "text": "Restore Tabs from Bookmarks",
          "link": "/bookmarks/restore-tabs"
        }
      ]
    },
    {
      "text": "Cloud Sync",
      "collapsed": false,
      "items": [
        {
          "text": "Overview",
          "link": "/cloud-sync/overview"
        },
        {
          "text": "Getting Started",
          "link": "/cloud-sync/getting-started"
        },
        {
          "text": "Sync Configuration",
          "link": "/cloud-sync/configuration"
        }
      ]
    },
    {
      "text": "Tab Panels",
      "collapsed": false,
      "items": [
        {
          "text": "Feature Introduction",
          "link": "/tab-panels/introduction"
        },
        {
          "text": "How to Use Tab Panels",
          "link": "/tab-panels/how-to-use"
        },
        {
          "text": "Use Cases",
          "link": "/tab-panels/use-cases"
        },
        {
          "text": "Troubleshooting",
          "link": "/tab-panels/troubleshooting"
        }
      ]
    },
    {
      "text": "Custom Themes",
      "collapsed": false,
      "items": [
        {
          "text": "Overview",
          "link": "/custom-themes/overview"
        },
        {
          "text": "Theme Configuration",
          "link": "/custom-themes/configuration"
        },
        {
          "text": "Font Size Adjustment",
          "link": "/custom-themes/font-size"
        },
        {
          "text": "Avatar Size Settings",
          "link": "/custom-themes/avatar-size"
        },
        {
          "text": "Icon Size Settings",
          "link": "/custom-themes/icon-size"
        },
        {
          "text": "List Style Settings (Spacing/Divider/Radius)",
          "link": "/custom-themes/list-spacing"
        },
        {
          "text": "Background Settings",
          "link": "/custom-themes/background"
        },
        {
          "text": "Reference Documentation",
          "link": "/custom-themes/reference"
        }
      ]
    }
  ],
  "logo": "https://static.rabbitpair.com/public/assets/icon/128x128.png",
  "search": {
    "provider": "local",
    "options": {
      "locales": {
        "ko": {
          "translations": {
            "button": {
              "buttonText": "문서 검색",
              "buttonAriaLabel": "문서 검색"
            },
            "modal": {
              "noResultsText": "관련 결과를 찾을 수 없습니다",
              "resetButtonTitle": "검색 조건 지우기",
              "footer": {
                "selectText": "선택",
                "navigateText": "이동"
              }
            }
          }
        },
        "zh": {
          "translations": {
            "button": {
              "buttonText": "搜索文檔",
              "buttonAriaLabel": "搜索文檔"
            },
            "modal": {
              "noResultsText": "無法找到相關結果",
              "resetButtonTitle": "清除查詢條件",
              "footer": {
                "selectText": "選擇",
                "navigateText": "切換"
              }
            }
          }
        },
        "ja": {
          "translations": {
            "button": {
              "buttonText": "ドキュメントを検索",
              "buttonAriaLabel": "ドキュメントを検索"
            },
            "modal": {
              "noResultsText": "関連する結果が見つかりません",
              "resetButtonTitle": "検索条件をクリア",
              "footer": {
                "selectText": "選択",
                "navigateText": "切り替え"
              }
            }
          }
        }
      }
    }
  },
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/RabbitPair/colorful_sidepanel_tabs_extension"
    },
    {
      "icon": {
        "svg": "<svg viewBox=\"0 0 24 24\"><path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z\"/></svg>"
      },
      "link": "https://www.rabbitpair.com"
    }
  ],
  "footer": {
    "message": "",
    "copyright": "Copyright © 2025 VertiTab Team"
  }
}

Page Data

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

Page Frontmatter

{
  "outline": "deep"
}

More

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