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": "首页",
      "link": "/"
    },
    {
      "text": "文档中心",
      "activeMatch": "/note/",
      "items": [
        {
          "text": "《JavaSE》笔记",
          "link": "/note/javase/"
        },
        {
          "text": "《JavaWeb》笔记",
          "link": "/note/javaweb/"
        },
        {
          "text": "《Maven》笔记",
          "link": "/note/maven/"
        }
      ]
    }
  ],
  "sidebar": [
    {
      "text": "《JavaSE》笔记",
      "items": [
        {
          "text": "day01-Java基础语法",
          "link": "/note/javase/day01-javase-basic"
        },
        {
          "text": "day02-Java基础语法",
          "link": "/note/javase/day02-javase-basic"
        },
        {
          "text": "day03-switch&循环语句",
          "link": "/note/javase/day03-switch-loop"
        },
        {
          "text": "day04-IDEA工具&数组",
          "link": "/note/javase/day04-idea-arr"
        },
        {
          "text": "day05-方法",
          "link": "/note/javase/day05-method"
        },
        {
          "text": "day06-Debug&基础练习",
          "link": "/note/javase/day06-debug-practice"
        },
        {
          "text": "day07-面向对象",
          "link": "/note/javase/day07-oop"
        },
        {
          "text": "day08-常用API",
          "link": "/note/javase/day08-api"
        },
        {
          "text": "day09-ArrayList集合&学生管理系统",
          "link": "/note/javase/day09-arraylist-collection"
        },
        {
          "text": "day10-继承&修饰符",
          "link": "/note/javase/day10-inheritance-modifiers"
        },
        {
          "text": "day11-多态&抽象类&接口",
          "link": "/note/javase/day11-polymorphism-abstract-interface"
        },
        {
          "text": "day12-内部类&API",
          "link": "/note/javase/day12-interneal-api"
        },
        {
          "text": "day13-常用API&异常",
          "link": "/note/javase/day13-api-exception"
        },
        {
          "text": "day14-集合",
          "link": "/note/javase/day14-collection"
        },
        {
          "text": "day15-集合",
          "link": "/note/javase/day15-collection"
        },
        {
          "text": "day16-集合",
          "link": "/note/javase/day16-collection"
        },
        {
          "text": "day17-File&递归&字节流",
          "link": "/note/javase/day17-Ffile-recursion-stream"
        },
        {
          "text": "day18-字节缓冲流&字符流",
          "link": "/note/javase/day18-byte-buffer-stream-character-stream"
        },
        {
          "text": "day19-IO流&Properties集合",
          "link": "/note/javase/day19-io-stream-properties-collection"
        },
        {
          "text": "day20-多线程",
          "link": "/note/javase/day20-multithread-"
        },
        {
          "text": "day21-网络编程",
          "link": "/note/javase/day21-network-programming"
        },
        {
          "text": "day22-Lambda&方法引用",
          "link": "/note/javase/day22-lambda-methond-reference"
        },
        {
          "text": "day23-函数式接口&Stream流",
          "link": "/note/javase/day23-fuctional-interface-stream-flow"
        },
        {
          "text": "day24-类加载器&反射&模块化",
          "link": "/note/javase/day24-class-loader-reflect-modularization"
        }
      ],
      "collapsed": true
    },
    {
      "text": "《JavaWeb》笔记",
      "items": [
        {
          "text": "day01-MySQL基础",
          "link": "/note/javaweb/day01-mysql-basic"
        },
        {
          "text": "day02-MySQL高级",
          "link": "/note/javaweb/day02-mysql-advanced"
        },
        {
          "text": "day03-JDBC",
          "link": "/note/javaweb/day03-jdbc"
        },
        {
          "text": "day04-Maven&MyBatis",
          "link": "/note/javaweb/day04-maven-mybatis"
        },
        {
          "text": "day05-Mybatis",
          "link": "/note/javaweb/day05-mybatis"
        },
        {
          "text": "day06-HTML&CSS",
          "link": "/note/javaweb/day06-html&css"
        },
        {
          "text": "day07-JavaScript",
          "link": "/note/javaweb/day07-javascript"
        },
        {
          "text": "day08-HTTP&Tomcat&Servlet",
          "link": "/note/javaweb/day08-http&tomcat&servlet"
        },
        {
          "text": "day09-Request&Response",
          "link": "/note/javaweb/day09-request&response"
        },
        {
          "text": "day10-JSP",
          "link": "/note/javaweb/day10-jsp"
        },
        {
          "text": "day11-会话技术",
          "link": "/note/javaweb/day11-conversation-tech"
        },
        {
          "text": "day12-Filter&Listener&Ajax",
          "link": "/note/javaweb/day12-filter&listener&ajax"
        },
        {
          "text": "day13-VUE&Element&综合案例",
          "link": "/note/javaweb/day13-vue&element&comprehensive-case"
        },
        {
          "text": "day14-综合案例",
          "link": "/note/javaweb/day14-comprehensive-case"
        }
      ],
      "collapsed": true
    },
    {
      "text": "《Maven》笔记",
      "items": [
        {
          "text": "day01-Maven基础",
          "link": "/note/maven/day01-maven-basic"
        }
      ],
      "collapsed": true
    }
  ],
  "outline": {
    "level": [
      2,
      3
    ]
  },
  "search": {
    "provider": "local"
  },
  "footer": {
    "message": "个人学习笔记",
    "copyright": "©2026"
  }
}

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.

个人学习笔记