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"
    },
    {
      "text": "API",
      "link": "/api/"
    }
  ],
  "sidebar": [
    {
      "text": "Examples",
      "items": [
        {
          "text": "Markdown Examples",
          "link": "/markdown-examples"
        },
        {
          "text": "Runtime API Examples",
          "link": "/api-examples"
        }
      ]
    },
    {
      "text": "API",
      "items": [
        {
          "text": "Namespaces",
          "collapsed": true,
          "items": [
            {
              "text": "Stubs",
              "link": "/api/namespaces/Stubs/",
              "collapsed": true,
              "items": [
                {
                  "text": "Type Aliases",
                  "collapsed": true,
                  "items": [
                    {
                      "text": "Affiliations",
                      "link": "/api/namespaces/Stubs/type-aliases/Affiliations.md"
                    },
                    {
                      "text": "Categories",
                      "link": "/api/namespaces/Stubs/type-aliases/Categories.md"
                    },
                    {
                      "text": "ClassType",
                      "link": "/api/namespaces/Stubs/type-aliases/ClassType.md"
                    },
                    {
                      "text": "Libraries",
                      "link": "/api/namespaces/Stubs/type-aliases/Libraries.md"
                    },
                    {
                      "text": "SecurityLevel",
                      "link": "/api/namespaces/Stubs/type-aliases/SecurityLevel.md"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "text": "Classes",
          "collapsed": true,
          "items": [
            {
              "text": "DocketSearch",
              "link": "/api/classes/DocketSearch.md"
            },
            {
              "text": "GeneralSearch",
              "link": "/api/classes/GeneralSearch.md"
            },
            {
              "text": "NewDocketSearch",
              "link": "/api/classes/NewDocketSearch.md"
            }
          ]
        },
        {
          "text": "Type Aliases",
          "collapsed": true,
          "items": [
            {
              "text": "DocketSearchParams",
              "link": "/api/type-aliases/DocketSearchParams.md"
            },
            {
              "text": "DocketSearchResults",
              "link": "/api/type-aliases/DocketSearchResults.md"
            },
            {
              "text": "DownloadFileParams",
              "link": "/api/type-aliases/DownloadFileParams.md"
            },
            {
              "text": "GeneralSearchParams",
              "link": "/api/type-aliases/GeneralSearchParams.md"
            },
            {
              "text": "GeneralSearchResult",
              "link": "/api/type-aliases/GeneralSearchResult.md"
            },
            {
              "text": "NewDocketParams",
              "link": "/api/type-aliases/NewDocketParams.md"
            },
            {
              "text": "NewDocketResults",
              "link": "/api/type-aliases/NewDocketResults.md"
            }
          ]
        },
        {
          "text": "Functions",
          "collapsed": true,
          "items": [
            {
              "text": "downloadFile",
              "link": "/api/functions/downloadFile.md"
            },
            {
              "text": "generatePDF",
              "link": "/api/functions/generatePDF.md"
            }
          ]
        }
      ]
    }
  ],
  "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.