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

{
  "aside": true,
  "footer": {
    "copyright": "Copyright © 2024 - present xpna"
  },
  "logo": {
    "light": "/xpna-icon.svg",
    "dark": "/xpna-icon.svg",
    "alt": "xpna logo"
  },
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Glossary",
      "link": "/glossary"
    },
    {
      "text": "Contact Us",
      "link": "/contact-us"
    }
  ],
  "search": {
    "provider": "local"
  },
  "sidebar": [
    {
      "text": "Getting Started",
      "collapsed": false,
      "items": [
        {
          "text": "Getting Started",
          "link": "/getting-started"
        },
        {
          "text": "First Steps",
          "link": "/getting-started-first"
        },
        {
          "text": "Onboarding Codes",
          "link": "/onboarding-codes"
        }
      ]
    },
    {
      "text": "Task Pane",
      "collapsed": false,
      "items": [
        {
          "text": "Overview of the Task Pane",
          "link": "/taskpane"
        },
        {
          "text": "Home",
          "collapsed": true,
          "items": [
            {
              "text": "Overview of Home",
              "link": "/home"
            },
            {
              "text": "Context Aware",
              "collapsed": true,
              "items": [
                {
                  "text": "Overview of Context Aware Actions",
                  "link": "/context-aware"
                },
                {
                  "text": "Choose a Different Member",
                  "link": "/member-choose-different"
                },
                {
                  "text": "Commentary",
                  "link": "/commentary"
                },
                {
                  "text": "Convert Selection To Report",
                  "link": "/report-convert-selection"
                },
                {
                  "text": "DataGrid",
                  "link": "/datagrid-insert-update"
                },
                {
                  "text": "Data Send Writeback",
                  "link": "/data-send-writeback"
                },
                {
                  "text": "Drill to Transactions",
                  "link": "/data-drill-to-transactions"
                },
                {
                  "text": "Drilldown Member",
                  "link": "/member-drilldown"
                },
                {
                  "text": "Resolve Members",
                  "link": "/member-resolve"
                },
                {
                  "text": "Static Reports",
                  "link": "/static-reports"
                },
                {
                  "text": "Update Number",
                  "link": "/data-update-number"
                },
                {
                  "text": "Writeback Errors",
                  "link": "/data-writeback-errors"
                }
              ]
            }
          ]
        },
        {
          "text": "Members and Hierarchies",
          "collapsed": true,
          "items": [
            {
              "text": "Overview of Members and Hierarchies",
              "link": "/hierarchies"
            },
            {
              "text": "Manage Attributes",
              "link": "/hierarchy-attributes-manage"
            },
            {
              "text": "Manage Chart of Accounts",
              "link": "/hierarchy-chartofaccounts-manage"
            },
            {
              "text": "Manage Currencies",
              "link": "/hierarchy-currency-manage"
            },
            {
              "text": "Manage Hierarchies",
              "link": "/hierarchy-manage"
            },
            {
              "text": "Manage Member Mapping",
              "link": "/hierarchy-member-mapping-manage"
            },
            {
              "text": "Manage Non-financial Accounts",
              "link": "/hierarchy-non-financial-manage"
            },
            {
              "text": "Manage Scenarios",
              "link": "/hierarchy-scenario-manage"
            },
            {
              "text": "Manage 3-Way Forecasting Rules",
              "link": "/hierarchy-scenario-three-way-forecasting"
            }
          ]
        },
        {
          "text": "Connections",
          "collapsed": false,
          "items": [
            {
              "text": "Connectors",
              "collapsed": true,
              "items": [
                {
                  "text": "Overview of Connections",
                  "link": "/connections"
                },
                {
                  "text": "D365 Business Central",
                  "link": "/integrations-businesscentral"
                },
                {
                  "text": "NetSuite",
                  "link": "/integrations-netsuite"
                },
                {
                  "text": "QuickBooks Online",
                  "link": "/integrations-quickbooks"
                },
                {
                  "text": "SAP Business One",
                  "link": "/integrations-sapb1"
                },
                {
                  "text": "Xero",
                  "link": "/integrations-xero"
                }
              ]
            },
            {
              "text": "Data Loading",
              "collapsed": true,
              "items": [
                {
                  "text": "Overview of Data Loading",
                  "link": "/data-load-introduction"
                },
                {
                  "text": "Articles",
                  "link": "/data-load-articles"
                }
              ]
            }
          ]
        },
        {
          "text": "Workspaces",
          "collapsed": true,
          "items": [
            {
              "text": "Workspace Management",
              "link": "/workspace"
            },
            {
              "text": "Invitations",
              "link": "/invitations"
            },
            {
              "text": "Role-based Security",
              "collapsed": true,
              "items": [
                {
                  "text": "Introduction",
                  "link": "/workspace-role-based-security"
                },
                {
                  "text": "Security Roles",
                  "link": "/workspace-security-rules"
                }
              ]
            }
          ]
        },
        {
          "text": "Footer Actions",
          "link": "/footer-actions"
        }
      ]
    },
    {
      "text": "Functions",
      "collapsed": true,
      "items": [
        {
          "text": "Overview of Functions",
          "link": "/functions"
        },
        {
          "text": "Comment",
          "link": "/comment"
        },
        {
          "text": "Data",
          "link": "/data"
        },
        {
          "text": "DataGrid",
          "link": "/datagrid"
        },
        {
          "text": "DataSend",
          "link": "/datasend"
        },
        {
          "text": "DataWrite",
          "link": "/datawrite"
        },
        {
          "text": "Info",
          "link": "/info"
        },
        {
          "text": "Member",
          "link": "/member"
        },
        {
          "text": "Suppress",
          "link": "/suppress"
        }
      ]
    },
    {
      "text": "Measures and special hierarchies",
      "collapsed": true,
      "items": [
        {
          "text": "Measures",
          "link": "/measures"
        },
        {
          "text": "Periods",
          "link": "/periods"
        },
        {
          "text": "Relative Periods",
          "link": "/relative-periods"
        }
      ]
    },
    {
      "text": "Power BI",
      "collapsed": true,
      "items": [
        {
          "text": "Getting Started",
          "link": "/powerbi-gettingstarted"
        },
        {
          "text": "Workspace Enablement",
          "link": "/powerbi-workspaces"
        },
        {
          "text": "User Access",
          "link": "/powerbi-users"
        },
        {
          "text": "Connecting",
          "link": "/powerbi-connecting"
        },
        {
          "text": "Grid Visual",
          "link": "/powerbi-viz-grid"
        }
      ]
    },
    {
      "text": "Troubleshooting",
      "collapsed": true,
      "items": [
        {
          "text": "Excel Addin",
          "link": "/troubleshooting-addin"
        },
        {
          "text": "Managed Deployment",
          "link": "/microsoft365"
        },
        {
          "text": "Onboarding",
          "link": "/troubleshooting-onboarding"
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "youtube",
      "link": "https://www.youtube.com/@xpnaco"
    },
    {
      "icon": "linkedin",
      "link": "https://linkedin.com/company/xpna"
    }
  ]
}

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.