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": "Getting Started",
      "link": "/getting-started/what-is-aichiki"
    }
  ],
  "sidebar": [
    {
      "text": "Getting Started",
      "items": [
        {
          "text": "What is AICHIKI?",
          "link": "/getting-started/what-is-aichiki"
        },
        {
          "text": "Creating an account",
          "link": "/getting-started/create-account"
        },
        {
          "text": "Identities explained",
          "link": "/getting-started/identities"
        },
        {
          "text": "Settings & Preferences",
          "link": "/getting-started/settings"
        },
        {
          "text": "Supported platforms",
          "link": "/getting-started/platforms"
        },
        {
          "text": "Multilingual use",
          "link": "/getting-started/multilingual"
        }
      ]
    },
    {
      "text": "Subscription Plans",
      "items": [
        {
          "text": "Plans & Features",
          "link": "/premium/features"
        }
      ]
    },
    {
      "text": "Chatting with Characters",
      "items": [
        {
          "text": "Starting a chat",
          "link": "/chatting/start-chat"
        },
        {
          "text": "Public vs private characters",
          "link": "/chatting/public-private"
        },
        {
          "text": "Chat Settings & Features",
          "link": "/chatting/chat-options"
        },
        {
          "text": "Background Customization",
          "link": "/chatting/background-customization"
        },
        {
          "text": "Do they remember?",
          "link": "/chatting/memory"
        },
        {
          "text": "Bookmarks",
          "link": "/chatting/bookmarks"
        }
      ]
    },
    {
      "text": "Characters",
      "items": [
        {
          "text": "Browse & discover characters",
          "link": "/characters/browse-characters"
        },
        {
          "text": "How to create",
          "link": "/characters/create"
        },
        {
          "text": "Edit character settings",
          "link": "/characters/editing"
        },
        {
          "text": "Preloaded Memories",
          "link": "/characters/preloaded-memories"
        },
        {
          "text": "Public or private?",
          "link": "/characters/public-private"
        },
        {
          "text": "Strong bio examples",
          "link": "/characters/bio-examples"
        }
      ]
    },
    {
      "text": "Using AICHIKI",
      "items": [
        {
          "text": "Who is AICHIKI?",
          "link": "/aichiki/about"
        },
        {
          "text": "What makes her special?",
          "link": "/aichiki/differences"
        },
        {
          "text": "What she remembers",
          "link": "/aichiki/memory"
        },
        {
          "text": "How to chat with her",
          "link": "/aichiki/chatting"
        }
      ]
    },
    {
      "text": "Profiles & Identities",
      "items": [
        {
          "text": "What is an identity?",
          "link": "/identities/what"
        },
        {
          "text": "Create or switch identities",
          "link": "/identities/switch"
        },
        {
          "text": "Why identities matter",
          "link": "/identities/importance"
        }
      ]
    },
    {
      "text": "Troubleshooting",
      "items": [
        {
          "text": "Can't log in",
          "link": "/troubleshooting/login"
        },
        {
          "text": "Can't create character",
          "link": "/troubleshooting/create-character"
        },
        {
          "text": "Can't download images",
          "link": "/troubleshooting/image-download"
        },
        {
          "text": "Can't chat with my private character",
          "link": "/troubleshooting/private-character-access"
        },
        {
          "text": "Can't find enough characters",
          "link": "/troubleshooting/not-enough-characters"
        },
        {
          "text": "Can't find dark/light mode",
          "link": "/troubleshooting/theme-toggle"
        },
        {
          "text": "Chat not loading",
          "link": "/troubleshooting/chat-issues"
        },
        {
          "text": "Bookmarks not saving",
          "link": "/troubleshooting/bookmarks"
        }
      ]
    },
    {
      "text": "Privacy & Safety",
      "items": [
        {
          "text": "Account safety",
          "link": "/privacy/safety"
        },
        {
          "text": "Content rules",
          "link": "/privacy/rules"
        },
        {
          "text": "Report content",
          "link": "/privacy/reporting"
        }
      ]
    },
    {
      "text": "Contact & Feedback",
      "items": [
        {
          "text": "Contact support",
          "link": "/contact/support"
        },
        {
          "text": "Send feedback",
          "link": "/contact/feedback"
        },
        {
          "text": "Join our Discord",
          "link": "/contact/discord"
        }
      ]
    }
  ],
  "socialLinks": [
    {
      "icon": "discord",
      "link": "https://discord.gg/z8r5X8pP9y"
    }
  ]
}

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.