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": "Accueil",
      "link": "/"
    },
    {
      "text": "Ressources",
      "items": [
        {
          "text": "Outils",
          "link": "/outils",
          "activeMatch": "^/outils/"
        },
        {
          "text": "Articles",
          "link": "/articles/",
          "activeMatch": "^/articles/"
        },
        {
          "text": "Extensions",
          "link": "/extensions",
          "activeMatch": "^/extensions/"
        },
        {
          "text": "Livres",
          "link": "/livres",
          "activeMatch": "^/livres/"
        },
        {
          "text": "Logiciels",
          "link": "/logiciels",
          "activeMatch": "^/logiciels/"
        },
        {
          "text": "Programmation",
          "link": "/programmation",
          "activeMatch": "^/programmation/"
        },
        {
          "text": "Services",
          "link": "/services",
          "activeMatch": "^/services/"
        }
      ]
    },
    {
      "text": "Documentation",
      "items": [
        {
          "text": "PostgreSQL 17",
          "link": "https://docs.postgresql.fr/17/"
        },
        {
          "text": "PostgreSQL 16",
          "link": "https://docs.postgresql.fr/16/"
        },
        {
          "text": "PostgreSQL 15",
          "link": "https://docs.postgresql.fr/15/"
        },
        {
          "text": "PostgreSQL 14",
          "link": "https://docs.postgresql.fr/14/"
        },
        {
          "text": "PostgreSQL 13",
          "link": "https://docs.postgresql.fr/13/"
        }
      ]
    },
    {
      "text": "Liens",
      "items": [
        {
          "text": "PostgreSQLFr",
          "link": "https://www.postgresql.fr/"
        },
        {
          "text": "Documentation",
          "link": "https://docs.postgresql.fr/"
        },
        {
          "text": "Forum",
          "link": "https://forums.postgresql.fr/"
        },
        {
          "text": "Planete PG",
          "link": "https://planete.postgresql.fr/"
        }
      ]
    },
    {
      "text": "PG 17.6",
      "items": [
        {
          "text": "Téléchargement",
          "items": [
            {
              "text": "Windows",
              "link": "https://www.postgresql.org/download/windows/"
            },
            {
              "text": "Mac OS",
              "link": "https://www.postgresql.org/download/macosx/"
            },
            {
              "text": "Linux",
              "link": "https://www.postgresql.org/download/linux/"
            }
          ]
        }
      ]
    }
  ],
  "sidebar": [
    {
      "text": "Articles",
      "items": [
        {
          "text": "Generalité",
          "link": "/articles/generalite"
        },
        {
          "text": "Indexes",
          "link": "/articles/indexes"
        },
        {
          "text": "Maintenance",
          "link": "/articles/maintenance"
        },
        {
          "text": "Replication",
          "link": "/articles/replication"
        },
        {
          "text": "Sauvegarde",
          "link": "/articles/sauvegarde"
        },
        {
          "text": "Types",
          "link": "/articles/types"
        }
      ]
    },
    {
      "text": "Programmation",
      "items": [
        {
          "text": "Langage C",
          "link": "/programmation/c"
        },
        {
          "text": "Java",
          "link": "/programmation/java"
        },
        {
          "text": "PHP",
          "link": "/programmation/php"
        },
        {
          "text": "Python",
          "link": "/programmation/python"
        },
        {
          "text": "PLpgSQL",
          "link": "/programmation/plpgsql"
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/5432-fr/5432.fr"
    },
    {
      "icon": "linkedin",
      "link": "https://www.linkedin.com/groups/13044096/"
    }
  ],
  "footer": {
    "message": "Released under <a href=\"http://creativecommons.org/licenses/by-sa/4.0/deed.fr\">CC BY-SA 4.0</a>.",
    "copyright": "Copyright © 2016-2025 Christophe Chauvet"
  },
  "lastUpdated": {
    "text": "Updated at",
    "formatOptions": {
      "dateStyle": "full",
      "timeStyle": "medium"
    }
  }
}

Page Data

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

Page Frontmatter

{
  "outline": "deep"
}

More

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

Released under CC BY-SA 4.0.