These composables are auto-imported in Nitro server context (API routes, middleware, plugins).
getPagesType: (event?: H3Event) => Promise<Map<string, PageEntry>>
Returns all indexed pages as a Map keyed by route.
export default defineEventHandler(async (event) => {
const pages = await getPages(event)
return Array.from(pages.values())
})
PageEntry:
| Property | Type | Description |
|---|---|---|
route | string | Page route (e.g., /about) |
title | string | Page title |
description | string | Meta description |
headings | string | Pipe-separated headings (e.g., h1:Title|h2:Subtitle) |
updatedAt | string | ISO timestamp |
getPagesListType: (event?: H3Event) => Promise<PageListItem[]>
Returns pages as a flat array (used by MCP tools).
export default defineEventHandler(async (event) => {
const query = getQuery(event).q as string
const pages = await getPagesList(event)
return pages.filter(p =>
p.title.toLowerCase().includes(query.toLowerCase())
)
})
getErrorRoutesType: (event?: H3Event) => Promise<Set<string>>
Returns routes that returned errors during prerendering.
export default defineEventHandler(async (event) => {
const errors = await getErrorRoutes(event)
return {
healthy: errors.size === 0,
errorCount: errors.size,
routes: Array.from(errors)
}
})
indexPageType: (route: string, html: string, options?: IndexPageOptions) => Promise<IndexPageResult>
Manually index a page. Requires runtimeIndexing.enabled.
export default defineEventHandler(async (event) => {
const { path } = await readBody(event)
const html = await $fetch(path)
return indexPage(path, html, { force: true })
})
Options:
| Option | Type | Default | Description |
|---|---|---|---|
ttl | number | config value | Override TTL check |
force | boolean | false | Re-index even if fresh |
skipHook | boolean | false | Skip ai-ready:page:indexed hook |
Result:
| Property | Type | Description |
|---|---|---|
success | boolean | Whether indexing succeeded |
skipped | boolean | true if page was fresh |
isUpdate | boolean | true if updating existing entry |
data | object | Page data if successful |
error | string | Error message if failed |
indexPageByRouteType: (route: string, event?: H3Event, options?: IndexPageOptions) => Promise<IndexPageResult>
Fetch HTML and index in one call.
export default defineNitroPlugin(async () => {
// Pre-warm important pages on startup
const routes = ['/', '/docs', '/pricing']
await Promise.all(routes.map(r => indexPageByRoute(r)))
})
The composables read from different sources based on context:
| Context | Source |
|---|---|
| Development | Empty (no data) |
| Prerender | Filesystem JSONL |
Runtime + runtimeIndexing | Unstorage |
| Runtime (default) | Static pages.json |