Skip to content
On this page

API Reference

VitePress offers several built in API to let you access app data. VitePress also comes with few built-in component that can be used globally.

The helper methods are globally importable from vitepress and are typically used in custom theme Vue components. However, they are also usable inside .md pages because markdown files are compiled into Vue single-file components.

Methods that start with use* indicates that it is a Vue 3 Composition API function that can only be used inside setup() or <script setup>.


Returns page-specific data. The returned object has the following type:

interface VitePressData<T = any> {
  site: Ref<SiteData<T>>
  page: Ref<PageData>
  theme: Ref<T> // themeConfig from .vitepress/config.js
  frontmatter: Ref<PageData['frontmatter']>
  title: Ref<string>
  description: Ref<string>
  lang: Ref<string>
  isDark: Ref<boolean>
  dir: Ref<string>
  localeIndex: Ref<string>


<script setup>
import { useData } from 'vitepress'

const { theme } = useData()

  <h1>{{ theme.footer.copyright }}</h1>


Returns the current route object with the following type:

interface Route {
  path: string
  data: PageData
  component: Component | null


Returns the VitePress router instance so you can programmatically navigate to another page.

interface Router {
  route: Route
  go: (href?: string) => Promise<void>


  • Type: (path: string) => string

Appends the configured base to a given URL path. Also see Base URL.

<Content />

The <Content /> component displays the rendered markdown contents. Useful when creating your own theme.

  <h1>Custom Layout!</h1>
  <Content />

<ClientOnly />

The <ClientOnly /> component renders its slot only at client side.

Because VitePress applications are server-rendered in Node.js when generating static builds, any Vue usage must conform to the universal code requirements. In short, make sure to only access Browser / DOM APIs in beforeMount or mounted hooks.

If you are using or demoing components that are not SSR-friendly (for example, contain custom directives), you can wrap them inside the ClientOnly component.

  <NonSSRFriendlyComponent />

Released under the MIT License.