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
{
"logo": "/images/logo-cw-h.svg",
"siteTitle": false,
"editLink": {
"pattern": "https://github.com/windwalker-io/windwalker-io.github.io/blob/master/:path"
},
"outline": {
"level": [
2,
3
]
},
"nav": [
{
"text": "Home",
"link": "/"
},
{
"text": "Documentations",
"items": [
{
"text": "Guide",
"link": "/documentation/guides/start/"
},
{
"text": "Framework",
"link": "#"
},
{
"text": "Components",
"link": "/documentation/components/"
}
]
},
{
"text": "Unicorn RAD",
"link": "#"
},
{
"text": "Skills",
"link": "/agent-skills"
},
{
"text": "Status",
"link": "status"
},
{
"text": "Others",
"link": "#"
}
],
"sidebar": {
"/documentation/guides": [
{
"text": "Start",
"items": [
{
"text": "Installation",
"link": "/documentation/guides/start/"
},
{
"text": "Debugging",
"link": "/documentation/guides/start/debugging"
}
]
},
{
"text": "MVC Basic",
"items": [
{
"text": "Getting Started",
"link": "/documentation/guides/mvc/getting-started"
},
{
"text": "Entity, Migrations and Seeders",
"link": "/documentation/guides/mvc/modeling"
},
{
"text": "Create Views",
"link": "/documentation/guides/mvc/view"
},
{
"text": "Admin and Forms",
"link": "/documentation/guides/mvc/admin"
}
]
},
{
"text": "RAD with Unicorn",
"items": [
{
"text": "Overview",
"link": "/documentation/guides/rad/"
},
{
"text": "Project Setup",
"link": "/documentation/guides/rad/project-setup"
},
{
"text": "Install the Unicorn Package",
"link": "/documentation/guides/rad/unicorn-installation"
},
{
"text": "Entities, Migrations and Seeders",
"link": "/documentation/guides/rad/modeling"
},
{
"text": "Admin Grid",
"link": "/documentation/guides/rad/admin-grid"
},
{
"text": "Advanced Grid Features",
"link": "/documentation/guides/rad/advanced-grid"
},
{
"text": "Edit Forms and Saving",
"link": "/documentation/guides/rad/edit-forms"
}
]
}
],
"/documentation/components": [
{
"text": "Core",
"items": [
{
"text": "Attributes",
"link": "/documentation/components/attributes/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/attributes/"
},
{
"text": "Available Types & Actions",
"link": "/documentation/components/attributes/available-type-actions"
},
{
"text": "Writing Handlers",
"link": "/documentation/components/attributes/write-handlers"
},
{
"text": "Miscellaneous",
"link": "/documentation/components/attributes/misc"
}
]
},
{
"text": "DI",
"link": "/documentation/components/di/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/di/"
},
{
"text": "Basic Usage",
"link": "/documentation/components/di/basic-usage"
},
{
"text": "Parameters",
"link": "/documentation/components/di/parameters"
},
{
"text": "Attributes",
"link": "/documentation/components/di/attributes"
},
{
"text": "Tagged Services",
"link": "/documentation/components/di/tagged-services"
},
{
"text": "Lazy Objects",
"link": "/documentation/components/di/lazy"
},
{
"text": "Multi Levels",
"link": "/documentation/components/di/multi-levels"
}
]
},
{
"text": "Promise",
"link": "/documentation/components/promise/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/promise/"
}
]
},
{
"text": "Reactor",
"link": "/documentation/components/reactor/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/reactor/"
},
{
"text": "Servers",
"link": "/documentation/components/reactor/servers"
},
{
"text": "HTTP",
"link": "/documentation/components/reactor/http"
},
{
"text": "WebSocket",
"link": "/documentation/components/reactor/websocket"
},
{
"text": "Sub-servers and Protocols",
"link": "/documentation/components/reactor/sub-servers"
},
{
"text": "Coroutine Server",
"link": "/documentation/components/reactor/coroutine-server"
},
{
"text": "Memory Tables",
"link": "/documentation/components/reactor/memory-tables"
}
]
}
]
},
{
"text": "System",
"items": [
{
"text": "Cache",
"link": "/documentation/components/cache/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/cache/"
},
{
"text": "CachePool",
"link": "/documentation/components/cache/cache-pool"
},
{
"text": "Storages",
"link": "/documentation/components/cache/storages"
},
{
"text": "Serializers",
"link": "/documentation/components/cache/serializers"
},
{
"text": "Tagged Caches",
"link": "/documentation/components/cache/tagged-pool"
}
]
},
{
"text": "Environment",
"link": "/documentation/components/environment/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/environment/"
},
{
"text": "Server and Platform",
"link": "/documentation/components/environment/server-and-platform"
},
{
"text": "PHP Helper",
"link": "/documentation/components/environment/php-helper"
}
]
},
{
"text": "Event",
"link": "/documentation/components/event/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/event/"
},
{
"text": "Event Objects",
"link": "/documentation/components/event/events"
},
{
"text": "Listeners and Subscribers",
"link": "/documentation/components/event/listeners"
},
{
"text": "Listener Providers",
"link": "/documentation/components/event/providers"
},
{
"text": "Dealers",
"link": "/documentation/components/event/dealers"
},
{
"text": "Observable",
"link": "/documentation/components/event/observable"
}
]
},
{
"text": "Filesystem",
"link": "/documentation/components/filesystem/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/filesystem/"
},
{
"text": "File Object",
"link": "/documentation/components/filesystem/file-object"
},
{
"text": "Iterating Files",
"link": "/documentation/components/filesystem/iterating-files"
},
{
"text": "Path Utilities",
"link": "/documentation/components/filesystem/path-utilities"
},
{
"text": "Path Collection",
"link": "/documentation/components/filesystem/path-collection"
},
{
"text": "Temporary Files",
"link": "/documentation/components/filesystem/temp-files"
},
{
"text": "Async Operations",
"link": "/documentation/components/filesystem/async-operations"
}
]
},
{
"text": "Queue",
"link": "/documentation/components/queue/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/queue/"
},
{
"text": "Writing Jobs",
"link": "/documentation/components/queue/writing-jobs"
},
{
"text": "Drivers",
"link": "/documentation/components/queue/drivers"
},
{
"text": "Workers",
"link": "/documentation/components/queue/workers"
},
{
"text": "Enqueuer",
"link": "/documentation/components/queue/enqueuer"
},
{
"text": "Failed Jobs",
"link": "/documentation/components/queue/failed-jobs"
}
]
},
{
"text": "Language",
"link": "/documentation/components/language/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/language/"
},
{
"text": "Translating Strings",
"link": "/documentation/components/language/translation"
},
{
"text": "Loading Files",
"link": "/documentation/components/language/loading"
},
{
"text": "Plural Forms",
"link": "/documentation/components/language/plurals"
},
{
"text": "Debugging",
"link": "/documentation/components/language/debugging"
}
]
}
]
},
{
"text": "HTTP",
"items": [
{
"text": "HTTP",
"link": "/documentation/components/http/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/http/"
},
{
"text": "Messages",
"link": "/documentation/components/http/messages"
},
{
"text": "HTTP Client",
"link": "/documentation/components/http/client"
},
{
"text": "Transports",
"link": "/documentation/components/http/transports"
},
{
"text": "Output",
"link": "/documentation/components/http/output"
},
{
"text": "Server",
"link": "/documentation/components/http/server"
},
{
"text": "Middleware",
"link": "/documentation/components/http/middleware"
}
]
},
{
"text": "Stream",
"link": "/documentation/components/stream/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/stream/"
},
{
"text": "Stream",
"link": "/documentation/components/stream/stream"
},
{
"text": "String Stream",
"link": "/documentation/components/stream/string-stream"
},
{
"text": "Gz Stream",
"link": "/documentation/components/stream/gz-stream"
},
{
"text": "Caching Stream",
"link": "/documentation/components/stream/caching-stream"
}
]
},
{
"text": "Session",
"link": "/documentation/components/session/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/session/"
},
{
"text": "Bridges",
"link": "/documentation/components/session/bridges"
},
{
"text": "Storage Handlers",
"link": "/documentation/components/session/handlers"
},
{
"text": "Cookies",
"link": "/documentation/components/session/cookies"
},
{
"text": "Flash Messages",
"link": "/documentation/components/session/flash-messages"
},
{
"text": "Security",
"link": "/documentation/components/session/security"
}
]
},
{
"text": "Uri",
"link": "/documentation/components/uri/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/uri/"
},
{
"text": "Uri",
"link": "/documentation/components/uri/uri"
},
{
"text": "URI Template",
"link": "/documentation/components/uri/uri-template"
},
{
"text": "Helpers",
"link": "/documentation/components/uri/helpers"
}
]
}
]
},
{
"text": "Security",
"items": [
{
"text": "Authentication",
"link": "/documentation/components/authentication/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/authentication/"
},
{
"text": "Authentication Methods",
"link": "/documentation/components/authentication/authentication-methods"
},
{
"text": "Results",
"link": "/documentation/components/authentication/results"
}
]
},
{
"text": "Authorization",
"link": "/documentation/components/authorization/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/authorization/"
}
]
},
{
"text": "Crypt",
"link": "/documentation/components/crypt/index",
"collapsed": true
},
{
"text": "Filter",
"link": "/documentation/components/filter/index",
"collapsed": true
},
{
"text": "SRP",
"link": "/documentation/components/srp/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/srp/"
},
{
"text": "Protocol",
"link": "/documentation/components/srp/protocol"
},
{
"text": "Configuration",
"link": "/documentation/components/srp/configuration"
},
{
"text": "Sample Flow",
"link": "/documentation/components/srp/sample-flow"
},
{
"text": "JavaScript",
"link": "/documentation/components/srp/javascript"
}
]
}
]
},
{
"text": "Database",
"items": [
{
"text": "Database",
"link": "/documentation/components/database/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/database/"
},
{
"text": "Connections",
"link": "/documentation/components/database/connections"
},
{
"text": "Queries",
"link": "/documentation/components/database/queries"
},
{
"text": "Hydrators",
"link": "/documentation/components/database/hydrators"
},
{
"text": "Writer",
"link": "/documentation/components/database/writer"
},
{
"text": "Tables",
"link": "/documentation/components/database/tables"
},
{
"text": "Databases and Schemas",
"link": "/documentation/components/database/databases-and-schemas"
},
{
"text": "Schema Diff",
"link": "/documentation/components/database/schema-diff"
},
{
"text": "Events",
"link": "/documentation/components/database/events"
}
]
},
{
"text": "Query",
"link": "/documentation/components/query/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/query/"
},
{
"text": "Selecting Data",
"link": "/documentation/components/query/select"
},
{
"text": "Conditions",
"link": "/documentation/components/query/where"
},
{
"text": "Joins",
"link": "/documentation/components/query/join"
},
{
"text": "Iteration",
"link": "/documentation/components/query/iteration"
},
{
"text": "Cursor Pagination",
"link": "/documentation/components/query/cursor-pagination"
},
{
"text": "Writing Data",
"link": "/documentation/components/query/writing"
},
{
"text": "Upsert",
"link": "/documentation/components/query/upsert"
},
{
"text": "Raw SQL and Bindings",
"link": "/documentation/components/query/expressions"
},
{
"text": "JSON",
"link": "/documentation/components/query/json"
},
{
"text": "Common Table Expressions",
"link": "/documentation/components/query/cte"
},
{
"text": "Rendering and Debugging",
"link": "/documentation/components/query/rendering"
},
{
"text": "Grammars and Escaper",
"link": "/documentation/components/query/grammars"
},
{
"text": "Method Index",
"link": "/documentation/components/query/methods"
}
]
},
{
"text": "ORM",
"link": "/documentation/components/orm/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/orm/"
},
{
"text": "Entities",
"link": "/documentation/components/orm/entities"
},
{
"text": "Attributes",
"link": "/documentation/components/orm/attributes"
},
{
"text": "Casting",
"link": "/documentation/components/orm/casting"
},
{
"text": "Hydration",
"link": "/documentation/components/orm/hydration"
},
{
"text": "Querying",
"link": "/documentation/components/orm/querying"
},
{
"text": "Persisting Data",
"link": "/documentation/components/orm/persisting"
},
{
"text": "Events",
"link": "/documentation/components/orm/events"
},
{
"text": "Energize",
"link": "/documentation/components/orm/energize"
},
{
"text": "UUID",
"link": "/documentation/components/orm/uuid"
},
{
"text": "Optimistic Locking",
"link": "/documentation/components/orm/optimistic-lock"
},
{
"text": "Nested Sets",
"link": "/documentation/components/orm/nested-set"
},
{
"text": "Custom Mappers",
"link": "/documentation/components/orm/mappers"
}
]
},
{
"text": "Pool",
"link": "/documentation/components/pool/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/pool/"
},
{
"text": "Connection Pool",
"link": "/documentation/components/pool/connection-pool"
},
{
"text": "Connections",
"link": "/documentation/components/pool/connections"
},
{
"text": "Health and Lifetime",
"link": "/documentation/components/pool/health-and-lifetime"
},
{
"text": "Swoole Stack",
"link": "/documentation/components/pool/swoole-stack"
}
]
}
]
},
{
"text": "Data",
"items": [
{
"text": "Scalars",
"link": "/documentation/components/scalars/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/scalars/"
},
{
"text": "Array Object",
"link": "/documentation/components/scalars/array-object"
},
{
"text": "String Object",
"link": "/documentation/components/scalars/string-object"
}
]
},
{
"text": "Data",
"link": "/documentation/components/data/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/data/"
},
{
"text": "Collection",
"link": "/documentation/components/data/collection"
},
{
"text": "Record",
"link": "/documentation/components/data/record"
},
{
"text": "Formats",
"link": "/documentation/components/data/formats"
}
]
}
]
},
{
"text": "HTML & Rendering",
"items": [
{
"text": "DOM",
"link": "/documentation/components/dom/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/dom/"
},
{
"text": "Elements",
"link": "/documentation/components/dom/elements"
},
{
"text": "Parsing and Rendering",
"link": "/documentation/components/dom/parsing-and-rendering"
}
]
},
{
"text": "HTML",
"link": "/documentation/components/html/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/html/"
},
{
"text": "Helpers",
"link": "/documentation/components/html/helpers"
},
{
"text": "Grid",
"link": "/documentation/components/html/grid"
}
]
},
{
"text": "Form",
"link": "/documentation/components/form/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/form/"
},
{
"text": "Defining Forms",
"link": "/documentation/components/form/defining"
},
{
"text": "Fields",
"link": "/documentation/components/form/fields"
},
{
"text": "Choice Fields",
"link": "/documentation/components/form/choices"
},
{
"text": "Data Lifecycle",
"link": "/documentation/components/form/data"
},
{
"text": "Rendering",
"link": "/documentation/components/form/rendering"
}
]
},
{
"text": "Edge",
"link": "/documentation/components/edge/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/edge/"
},
{
"text": "Template Syntax",
"link": "/documentation/components/edge/syntax"
},
{
"text": "Layouts & Sections",
"link": "/documentation/components/edge/layouts"
},
{
"text": "Components",
"link": "/documentation/components/edge/components"
},
{
"text": "Template Loaders",
"link": "/documentation/components/edge/loaders"
},
{
"text": "Compiled Cache",
"link": "/documentation/components/edge/cache"
},
{
"text": "Extending Edge",
"link": "/documentation/components/edge/extending"
},
{
"text": "Differences from Blade",
"link": "/documentation/components/edge/blade-differences"
}
]
},
{
"text": "Renderer",
"link": "/documentation/components/renderer/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/renderer/"
},
{
"text": "Engine Renderers",
"link": "/documentation/components/renderer/engines"
},
{
"text": "Composite Renderer",
"link": "/documentation/components/renderer/composite"
}
]
}
]
},
{
"text": "Utilities",
"items": [
{
"text": "Test",
"link": "/documentation/components/test/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/test/"
},
{
"text": "Assertions",
"link": "/documentation/components/test/assertions"
},
{
"text": "Accessing Members",
"link": "/documentation/components/test/accessors"
},
{
"text": "Database Tests",
"link": "/documentation/components/test/database"
},
{
"text": "Swoole Tests",
"link": "/documentation/components/test/swoole"
}
]
},
{
"text": "Utilities",
"link": "/documentation/components/utilities/index",
"collapsed": true,
"items": [
{
"text": "Overview",
"link": "/documentation/components/utilities/"
},
{
"text": "Arr",
"link": "/documentation/components/utilities/arr"
},
{
"text": "Array Sync",
"link": "/documentation/components/utilities/arr-sync"
},
{
"text": "Str",
"link": "/documentation/components/utilities/str"
},
{
"text": "Type Cast",
"link": "/documentation/components/utilities/type-cast"
},
{
"text": "Assert",
"link": "/documentation/components/utilities/assert"
},
{
"text": "Helpers",
"link": "/documentation/components/utilities/helpers"
},
{
"text": "Object Helpers",
"link": "/documentation/components/utilities/object-helpers"
},
{
"text": "Text Transforms",
"link": "/documentation/components/utilities/text-transforms"
},
{
"text": "Identifiers",
"link": "/documentation/components/utilities/identifiers"
},
{
"text": "Exceptions",
"link": "/documentation/components/utilities/exceptions"
},
{
"text": "Attributes",
"link": "/documentation/components/utilities/attributes"
},
{
"text": "Enum Metadata",
"link": "/documentation/components/utilities/enum-metadata"
},
{
"text": "Iterators",
"link": "/documentation/components/utilities/iterators"
}
]
}
]
}
]
},
"search": {
"provider": "local"
},
"socialLinks": [
{
"icon": "github",
"link": "https://github.com/windwalker-io/framework/"
}
],
"footer": {
"message": "Released under the MIT License.",
"copyright": "Copyright © 2026 <a href=\"https://simular.co/\" target=\"_blank\">Simular Inc.</a>."
}
}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.