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 ​

{
  "siteTitle": "Validation BR",
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Versão",
      "items": [
        {
          "text": "2.0.0 (current)",
          "link": "/v2/"
        },
        {
          "text": "1.6.4 (legacy)",
          "link": "/v1/"
        }
      ]
    }
  ],
  "logo": {
    "light": "/logo-light.jpg",
    "dark": "/logo-dark.jpg"
  },
  "sidebar": {
    "/v1/": [
      {
        "text": "Instalação",
        "link": "/v1/"
      },
      {
        "text": "Documentos",
        "items": [
          {
            "text": "CPF",
            "link": "/v1/cpf"
          },
          {
            "text": "CNPJ",
            "link": "/v1/cnpj"
          },
          {
            "text": "CNH",
            "link": "/v1/cnh"
          },
          {
            "text": "Telefone",
            "link": "/v1/phone"
          },
          {
            "text": "PIS / PASEP",
            "link": "/v1/pis-pasep"
          },
          {
            "text": "NUP17",
            "link": "/v1/nup17"
          },
          {
            "text": "Processo Judicial",
            "link": "/v1/judicial-process"
          },
          {
            "text": "RENAVAM",
            "link": "/v1/renavam"
          },
          {
            "text": "Título de Eleitor",
            "link": "/v1/tituloEleitor"
          },
          {
            "text": "Cód. Rastreamento Postal",
            "link": "/v1/postal-track-code"
          }
        ]
      },
      {
        "text": "Integração",
        "items": [
          {
            "text": "Class Validator",
            "link": "/v1/integrations/class-validator"
          },
          {
            "text": "Indicative",
            "link": "/v1/integrations/indicative"
          },
          {
            "text": "Joi",
            "link": "/v1/integrations/joi"
          },
          {
            "text": "Vuelidate",
            "link": "/v1/integrations/vuelidate"
          },
          {
            "text": "Yup",
            "link": "/v1/integrations/yup"
          }
        ]
      }
    ],
    "/v2/": [
      {
        "text": "Home",
        "link": "/v2"
      },
      {
        "text": "Instalação",
        "link": "/v2/install"
      },
      {
        "text": "Migrando da 1.x",
        "link": "/v2/migration"
      },
      {
        "text": "Documentos principais",
        "items": [
          {
            "text": "CPF",
            "link": "/v2/cpf"
          },
          {
            "text": "CNPJ",
            "link": "/v2/cnpj"
          },
          {
            "text": "CNH",
            "link": "/v2/cnh"
          },
          {
            "text": "Placa (CarPlate)",
            "link": "/v2/carplate"
          },
          {
            "text": "PIS / PASEP",
            "link": "/v2/pis-pasep"
          },
          {
            "text": "NUP17",
            "link": "/v2/nup17"
          },
          {
            "text": "Processo Judicial",
            "link": "/v2/judicial-process"
          },
          {
            "text": "RENAVAM",
            "link": "/v2/renavam"
          },
          {
            "text": "Título de Eleitor",
            "link": "/v2/tituloEleitor"
          },
          {
            "text": "Cód. Rastreamento Postal",
            "link": "/v2/postal-track-code"
          },
          {
            "text": "Boleto",
            "link": "/v2/boleto"
          },
          {
            "text": "CAEPF",
            "link": "/v2/caepf"
          },
          {
            "text": "CEP",
            "link": "/v2/cep"
          },
          {
            "text": "Certidão",
            "link": "/v2/certidao"
          },
          {
            "text": "CBI Sinter",
            "link": "/v2/cbi_sinter"
          },
          {
            "text": "Chave Pix",
            "link": "/v2/pix-key"
          },
          {
            "text": "Pix Copia e Cola",
            "link": "/v2/pix-copy-paste"
          }
        ]
      },
      {
        "text": "Validações auxiliares",
        "items": [
          {
            "text": "E-mail",
            "link": "/v2/email"
          },
          {
            "text": "Telefone",
            "link": "/v2/phone"
          },
          {
            "text": "UUID",
            "link": "/v2/uuid"
          },
          {
            "text": "UF",
            "link": "/v2/uf"
          }
        ]
      },
      {
        "text": "Integração",
        "items": [
          {
            "text": "Yup",
            "link": "/v2/integrations/yup"
          },
          {
            "text": "Zod",
            "link": "/v2/integrations/zod"
          },
          {
            "text": "Class Validator",
            "link": "/v2/integrations/class-validator"
          },
          {
            "text": "Vuelidate",
            "link": "/v2/integrations/vuelidate"
          },
          {
            "text": "Joi",
            "link": "/v2/integrations/joi"
          }
        ]
      }
    ],
    "/": [
      {
        "text": "Home",
        "link": "/v2"
      },
      {
        "text": "Instalação",
        "link": "/v2/install"
      },
      {
        "text": "Migrando da 1.x",
        "link": "/v2/migration"
      },
      {
        "text": "Documentos principais",
        "items": [
          {
            "text": "CPF",
            "link": "/v2/cpf"
          },
          {
            "text": "CNPJ",
            "link": "/v2/cnpj"
          },
          {
            "text": "CNH",
            "link": "/v2/cnh"
          },
          {
            "text": "Placa (CarPlate)",
            "link": "/v2/carplate"
          },
          {
            "text": "PIS / PASEP",
            "link": "/v2/pis-pasep"
          },
          {
            "text": "NUP17",
            "link": "/v2/nup17"
          },
          {
            "text": "Processo Judicial",
            "link": "/v2/judicial-process"
          },
          {
            "text": "RENAVAM",
            "link": "/v2/renavam"
          },
          {
            "text": "Título de Eleitor",
            "link": "/v2/tituloEleitor"
          },
          {
            "text": "Cód. Rastreamento Postal",
            "link": "/v2/postal-track-code"
          },
          {
            "text": "Boleto",
            "link": "/v2/boleto"
          },
          {
            "text": "CAEPF",
            "link": "/v2/caepf"
          },
          {
            "text": "CEP",
            "link": "/v2/cep"
          },
          {
            "text": "Certidão",
            "link": "/v2/certidao"
          },
          {
            "text": "CBI Sinter",
            "link": "/v2/cbi_sinter"
          },
          {
            "text": "Chave Pix",
            "link": "/v2/pix-key"
          },
          {
            "text": "Pix Copia e Cola",
            "link": "/v2/pix-copy-paste"
          }
        ]
      },
      {
        "text": "Validações auxiliares",
        "items": [
          {
            "text": "E-mail",
            "link": "/v2/email"
          },
          {
            "text": "Telefone",
            "link": "/v2/phone"
          },
          {
            "text": "UUID",
            "link": "/v2/uuid"
          },
          {
            "text": "UF",
            "link": "/v2/uf"
          }
        ]
      },
      {
        "text": "Integração",
        "items": [
          {
            "text": "Yup",
            "link": "/v2/integrations/yup"
          },
          {
            "text": "Zod",
            "link": "/v2/integrations/zod"
          },
          {
            "text": "Class Validator",
            "link": "/v2/integrations/class-validator"
          },
          {
            "text": "Vuelidate",
            "link": "/v2/integrations/vuelidate"
          },
          {
            "text": "Joi",
            "link": "/v2/integrations/joi"
          }
        ]
      }
    ]
  },
  "editLink": {
    "text": "Edite esta página no GitHub",
    "pattern": "https://github.com/klawdyo/validation-br-docs/tree/main/src/:path"
  },
  "lastUpdated": {
    "text": "Atualização",
    "formatOptions": {
      "dateStyle": "short",
      "timeStyle": "short",
      "timeZone": "America/Sao_Paulo"
    }
  },
  "returnToTopLabel": "Topo",
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/klawdyo/validation-br"
    },
    {
      "icon": "npm",
      "link": "https://npmjs.com/package/validation-br"
    }
  ]
}

Page Data ​

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

Page Frontmatter ​

{
  "outline": "deep"
}

More ​

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