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

{
  "search": {
    "provider": "local"
  },
  "editLink": {
    "pattern": "https://github.com/sebastianwessel/purista/tree/master/website/doc/:path",
    "text": "Edit this page on GitHub"
  },
  "outline": "deep",
  "lastUpdated": {
    "text": "Updated at",
    "formatOptions": {
      "dateStyle": "full",
      "timeStyle": "medium"
    }
  },
  "nav": [
    {
      "text": "Home",
      "link": "/"
    },
    {
      "text": "Handbook",
      "link": "/handbook/",
      "activeMatch": "/handbook/"
    },
    {
      "text": "Blog",
      "link": "/article/",
      "activeMatch": "/article/"
    },
    {
      "text": "API",
      "link": "/api/README",
      "activeMatch": "/api/"
    },
    {
      "text": "Resources",
      "link": "/resources/",
      "activeMatch": "/resources/"
    }
  ],
  "sidebar": {
    "/handbook/": {
      "base": "/handbook/",
      "items": [
        {
          "text": "Purista Handbook",
          "link": "index"
        },
        {
          "text": "Concept",
          "link": "concept"
        },
        {
          "text": "Principles",
          "link": "principles"
        },
        {
          "text": "Installation & Cli",
          "link": "cli"
        },
        {
          "text": "Quickstart",
          "link": "1_quickstart/",
          "items": [
            {
              "text": "Project Setup",
              "link": "1_quickstart/setup-the-purista-project"
            },
            {
              "text": "Project Structure",
              "link": "1_quickstart/project-folder-structures"
            },
            {
              "text": "Create A Service",
              "link": "1_quickstart/create-a-service"
            },
            {
              "text": "Add A Command",
              "link": "1_quickstart/add-the-first-command"
            },
            {
              "text": "Add A Subscription",
              "link": "1_quickstart/add-the-first-subscription"
            }
          ],
          "collapsed": true
        },
        {
          "text": "Building Business Logic",
          "link": "2_building_business-logic/",
          "items": [
            {
              "text": "Builders",
              "link": "2_building_business-logic/builders"
            },
            {
              "text": "Schemas & Validation",
              "link": "2_building_business-logic/schemas"
            },
            {
              "text": "Service",
              "link": "2_building_business-logic/service/",
              "items": [
                {
                  "text": "The Service Builder",
                  "link": "2_building_business-logic/service/the-service-builder"
                },
                {
                  "text": "Add A Service Configuration",
                  "link": "2_building_business-logic/service/add-a-service-config"
                },
                {
                  "text": "Unit Test The Service",
                  "link": "2_building_business-logic/service/unit-test-a-service"
                },
                {
                  "text": "Custom Service Class",
                  "link": "2_building_business-logic/service/custom-service-class"
                }
              ],
              "collapsed": true
            },
            {
              "text": "Command",
              "link": "2_building_business-logic/command/",
              "items": [
                {
                  "text": "The Command Builder",
                  "link": "2_building_business-logic/command/the-command-builder"
                },
                {
                  "text": "Invoke Other Command",
                  "link": "2_building_business-logic/command/invoke_command_from_command"
                },
                {
                  "text": "Expose As Http Endpoint",
                  "link": "2_building_business-logic/command/exposing-a-command-as-http-endpoint"
                },
                {
                  "text": "Test A Command",
                  "link": "2_building_business-logic/command/test-a-command"
                }
              ],
              "collapsed": true
            },
            {
              "text": "Subscription",
              "link": "2_building_business-logic/subscription/",
              "items": [
                {
                  "text": "The Subscription Builder",
                  "link": "2_building_business-logic/subscription/the-subscription-builder"
                },
                {
                  "text": "Unit Test A Subscription",
                  "link": "2_building_business-logic/subscription/unit-test-a-subscription"
                }
              ],
              "collapsed": true
            },
            {
              "text": "Custom Event Messages",
              "link": "2_building_business-logic/custom_events"
            },
            {
              "text": "Logging",
              "link": "2_building_business-logic/logging"
            },
            {
              "text": "Error Handling",
              "link": "2_building_business-logic/error-handling"
            },
            {
              "text": "Stores",
              "link": "2_building_business-logic/stores/",
              "items": [
                {
                  "text": "Config Stores",
                  "link": "2_building_business-logic/stores/config-stores"
                },
                {
                  "text": "Secret Stores",
                  "link": "2_building_business-logic/stores/secret-stores"
                },
                {
                  "text": "State Stores",
                  "link": "2_building_business-logic/stores/state-stores"
                }
              ],
              "collapsed": true
            },
            {
              "text": "Exposing Commands",
              "link": "2_building_business-logic/exposing_endpoints/",
              "items": [
                {
                  "text": "Graphql",
                  "link": "2_building_business-logic/exposing_endpoints/graphql_mutation_and_query"
                },
                {
                  "text": "Rest Api",
                  "link": "2_building_business-logic/exposing_endpoints/rest_api_http_endpoints"
                }
              ],
              "collapsed": true
            },
            {
              "text": "Http Client",
              "link": "2_building_business-logic/fetch_based_http_client"
            },
            {
              "text": "Advanced",
              "link": "2_building_business-logic/advanced/",
              "items": [
                {
                  "text": "Javascript Events",
                  "link": "2_building_business-logic/advanced/javascript_events"
                },
                {
                  "text": "Structure Of A Message",
                  "link": "2_building_business-logic/advanced/structure_of_a_message"
                }
              ],
              "collapsed": true
            }
          ],
          "collapsed": true
        },
        {
          "text": "Purista Ecosystem",
          "link": "3_eco_system/",
          "items": [
            {
              "text": "Event Bridges",
              "link": "3_eco_system/eventbridges/",
              "items": [
                {
                  "text": "Default Event Bridge",
                  "link": "3_eco_system/eventbridges/default_event_bridge"
                },
                {
                  "text": "Amqp Event Bridge",
                  "link": "3_eco_system/eventbridges/amqp"
                },
                {
                  "text": "Mqtt Event Bridge",
                  "link": "3_eco_system/eventbridges/mqtt"
                },
                {
                  "text": "Dapr Event Bridge",
                  "link": "3_eco_system/eventbridges/dapr"
                },
                {
                  "text": "Nats Event Bridge",
                  "link": "3_eco_system/eventbridges/nats"
                }
              ],
              "collapsed": true
            },
            {
              "text": "Stores",
              "link": "3_eco_system/stores"
            },
            {
              "text": "Http Server",
              "link": "3_eco_system/http_server"
            }
          ],
          "collapsed": true
        },
        {
          "text": "Open Telemetry",
          "link": "4_open_telemetry/",
          "items": [
            {
              "text": "Aws",
              "link": "4_open_telemetry/aws"
            },
            {
              "text": "Azure Monitor",
              "link": "4_open_telemetry/azure_monitor"
            },
            {
              "text": "Google Cloud Trace",
              "link": "4_open_telemetry/google_cloud_trace"
            },
            {
              "text": "Grafana",
              "link": "4_open_telemetry/grafana"
            },
            {
              "text": "Jaeger",
              "link": "4_open_telemetry/jaeger"
            },
            {
              "text": "Signnoz",
              "link": "4_open_telemetry/signoz"
            },
            {
              "text": "Teletrace",
              "link": "4_open_telemetry/teletrace"
            },
            {
              "text": "Uptrace",
              "link": "4_open_telemetry/uptrace"
            },
            {
              "text": "Zipkin",
              "link": "4_open_telemetry/zipkin"
            }
          ],
          "collapsed": true
        },
        {
          "text": "Deploy & Scale",
          "link": "5_deploy_and_scale/",
          "items": [
            {
              "text": "Monolithic",
              "link": "5_deploy_and_scale/monolithic"
            },
            {
              "text": "Edge",
              "link": "5_deploy_and_scale/edge"
            },
            {
              "text": "Microservice Style",
              "link": "5_deploy_and_scale/microservice_style/",
              "items": [
                {
                  "text": "Deploy To Kubernetes",
                  "link": "5_deploy_and_scale/microservice_style/kubernetes"
                },
                {
                  "text": "Deploy To Dapr",
                  "link": "5_deploy_and_scale/microservice_style/dapr"
                }
              ],
              "collapsed": true
            },
            {
              "text": "Serverless Function",
              "link": "5_deploy_and_scale/serverless_function_fass"
            }
          ],
          "collapsed": true
        },
        {
          "text": "Integrations",
          "link": "6_integrations/",
          "items": [
            {
              "text": "Temporal",
              "link": "6_integrations/temporal_and_purista/",
              "items": [
                {
                  "text": "Motivation",
                  "link": "6_integrations/temporal_and_purista/why_to_use_temporal_and_purista"
                },
                {
                  "text": "Setup Temporal",
                  "link": "6_integrations/temporal_and_purista/setup_temporal"
                },
                {
                  "text": "Purista To Temporal",
                  "link": "6_integrations/temporal_and_purista/connect_purista_to_temporal"
                },
                {
                  "text": "Temporal To Purista",
                  "link": "6_integrations/temporal_and_purista/connect_temporal_with_purista"
                },
                {
                  "text": "Opentelemetry",
                  "link": "6_integrations/temporal_and_purista/add_opentelementry"
                }
              ],
              "collapsed": true
            }
          ],
          "collapsed": true
        }
      ]
    },
    "/article/": {
      "base": "/article/",
      "items": [
        {
          "text": "Overview",
          "link": "index"
        },
        {
          "text": "Purista 1.11",
          "link": "2024-30-02-breaking-changes-in-purista-version-1-11-0"
        },
        {
          "text": "Version 1.10",
          "link": "2024-30-01-purista-typescript-cloud-framwork-version-1-10-0"
        },
        {
          "text": "Version 1.7",
          "link": "2023-01-06-purista-typescript-framework-version-1-7"
        },
        {
          "text": "Version 1.6",
          "link": "2023-20-05-purista-version-1-6-0"
        },
        {
          "text": "Version 1.5",
          "link": "2023-14-01-purista-typescript-framework-version_1_5_0"
        }
      ]
    },
    "/resources/": {
      "base": "/resources/",
      "items": [
        {
          "text": "Resources",
          "link": "index"
        },
        {
          "text": "Books",
          "link": "books"
        },
        {
          "text": "Articles",
          "link": "articles"
        }
      ]
    },
    "api": [
      {
        "text": "Core",
        "items": [
          {
            "text": "@purista/core",
            "link": "/api/modules/purista_core.md"
          },
          {
            "text": "@purista/hono-http-server",
            "link": "/api/modules/purista_hono_http_server.md"
          },
          {
            "text": "@purista/httpserver",
            "link": "/api/modules/purista_httpserver.md"
          }
        ]
      },
      {
        "text": "Event bridges",
        "items": [
          {
            "text": "@purista/amqpbridge",
            "link": "/api/modules/purista_amqpbridge.md"
          },
          {
            "text": "@purista/dapr-sdk",
            "link": "/api/modules/purista_dapr_sdk.md"
          },
          {
            "text": "@purista/mqttbridge",
            "link": "/api/modules/purista_mqttbridge.md"
          },
          {
            "text": "@purista/natsbridge",
            "link": "/api/modules/purista_natsbridge.md"
          }
        ]
      },
      {
        "text": "Config stores",
        "items": [
          {
            "text": "@purista/aws-config-store",
            "link": "/api/modules/purista_aws_config_store.md"
          },
          {
            "text": "@purista/dapr-sdk",
            "link": "/api/modules/purista_dapr_sdk.md"
          },
          {
            "text": "@purista/nats-config-store",
            "link": "/api/modules/purista_nats_config_store.md"
          },
          {
            "text": "@purista/redis-config-store",
            "link": "/api/modules/purista_redis_config_store.md"
          }
        ]
      },
      {
        "text": "Secret stores",
        "items": [
          {
            "text": "@purista/aws-secret-store",
            "link": "/api/modules/purista_aws_secret_store.md"
          },
          {
            "text": "@purista/azure-secret-store",
            "link": "/api/modules/purista_azure_secret_store.md"
          },
          {
            "text": "@purista/dapr-sdk",
            "link": "/api/modules/purista_dapr_sdk.md"
          },
          {
            "text": "@purista/gcloud-secret-store",
            "link": "/api/modules/purista_gcloud_secret_store.md"
          },
          {
            "text": "@purista/infisical-secret-store",
            "link": "/api/modules/purista_infisical_secret_store.md"
          }
        ]
      },
      {
        "text": "State stores",
        "items": [
          {
            "text": "@purista/dapr-sdk",
            "link": "/api/modules/purista_dapr_sdk.md"
          },
          {
            "text": "@purista/nats-state-store",
            "link": "/api/modules/purista_nats_state_store.md"
          },
          {
            "text": "@purista/redis-state-store",
            "link": "/api/modules/purista_redis_state_store.md"
          }
        ]
      },
      {
        "text": "Deployment SDK",
        "items": [
          {
            "text": "@purista/dapr-sdk",
            "link": "/api/modules/purista_dapr_sdk.md"
          },
          {
            "text": "@purista/k8s-sdk",
            "link": "/api/modules/purista_k8s_sdk.md"
          }
        ]
      }
    ]
  },
  "socialLinks": [
    {
      "icon": "github",
      "link": "https://github.com/sebastianwessel/purista"
    },
    {
      "icon": "twitter",
      "link": "https://twitter.com/purista_js"
    },
    {
      "icon": "discord",
      "link": "https://discord.gg/9feaUm3H2v"
    }
  ],
  "footer": {
    "message": "Made from developers for developers with ❤️",
    "copyright": "<a href=\"/privacy.html\">Privacy</a> | <a href=\"javascript:cc.showSettings()\">Cookie preferences</a> | <a href=\"/imprint.html\">Imprint</a>"
  }
}

Page Data

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

Page Frontmatter

{
  "outline": "deep"
}

More

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