Runtime Sync (Optional) · Nuxt AI Ready · Nuxt SEO

[NuxtSEO Pro](https://nuxtseo.com/ "Home")

- [Modules](https://nuxtseo.com/docs/nuxt-seo/getting-started/introduction)
- [Tools](https://nuxtseo.com/tools)
- [Pro](https://nuxtseo.com/pro)
- [Learn SEO](https://nuxtseo.com/learn-seo/nuxt) [Releases](https://nuxtseo.com/releases)

[Sign In](https://nuxtseo.com/auth/github)

[Nuxt SEO on GitHub](https://github.com/harlan-zw/nuxt-seo)

[User Guides](https://nuxtseo.com/docs/ai-ready/getting-started/introduction)

[API](https://nuxtseo.com/docs/ai-ready/api/config)

[Releases](https://nuxtseo.com/docs/ai-ready/releases/v1)

AI Ready

- [Switch to AI Ready](https://nuxtseo.com/docs/ai-ready/getting-started/introduction)
- [Switch to Nuxt SEO](https://nuxtseo.com/docs/nuxt-seo/getting-started/introduction)
- [Switch to Robots](https://nuxtseo.com/docs/robots/getting-started/introduction)
- [Switch to Sitemap](https://nuxtseo.com/docs/sitemap/getting-started/introduction)
- [Switch to OG Image](https://nuxtseo.com/docs/og-image/getting-started/introduction)
- [Switch to Schema.org](https://nuxtseo.com/docs/schema-org/getting-started/introduction)
- [Switch to Link Checker](https://nuxtseo.com/docs/link-checker/getting-started/introduction)
- [Switch to SEO Utils](https://nuxtseo.com/docs/seo-utils/getting-started/introduction)
- [Switch to Site Config](https://nuxtseo.com/docs/site-config/getting-started/introduction)
- [Switch to Skew Protection](https://nuxtseo.com/docs/skew-protection/getting-started/introduction)

Search…```k`` /`

v1.1.2

- [Discord Support](https://discord.com/invite/275MBUBvgP)

### Getting Started

- [Introduction](https://nuxtseo.com/docs/ai-ready/getting-started/introduction)
- [Installation](https://nuxtseo.com/docs/ai-ready/getting-started/installation)

### Core Concepts

- [AI Content Signals](https://nuxtseo.com/docs/ai-ready/guides/content-signals)
- [llms.txt Generation](https://nuxtseo.com/docs/ai-ready/guides/llms-txt)
- [Markdown Conversion](https://nuxtseo.com/docs/ai-ready/guides/markdown)
- [Model Context Protocol (MCP)](https://nuxtseo.com/docs/ai-ready/guides/mcp)
- [Runtime Sync (Optional)](https://nuxtseo.com/docs/ai-ready/guides/runtime-indexing)
- [Cloudflare Deployment](https://nuxtseo.com/docs/ai-ready/guides/cloudflare)
- [IndexNow](https://nuxtseo.com/docs/ai-ready/guides/indexnow)
- [CLI](https://nuxtseo.com/docs/ai-ready/guides/cli)

### Advanced

- [RAG Setup](https://nuxtseo.com/docs/ai-ready/advanced/rag-example)

Core Concepts

# Runtime Sync (Optional)

[Copy for LLMs](https://nuxtseo.com/docs/ai-ready/guides/runtime-indexing.md)

**Most sites don't need this.** Prerendering handles page indexing automatically. Use runtime sync only for sites with frequently changing content that you can't prerender.

## [When You Need Runtime Sync](#when-you-need-runtime-sync)

Enable runtime sync if your site has:

- **Dynamic pages** generated at runtime (e.g., user-generated content)
- **Frequently updated content** that changes between deploys
- **API-driven pages** where content comes from external sources

If your content only changes on deploy, stick with prerendering - it's faster and simpler.

## [How It Works](#how-it-works)

```
┌─────────────────────────────────────────────────────────────┐
│ Default: Prerendering (source of truth)                     │
│   Build time → crawl sitemap → create SQLite → compress    │
│   Cold start → restore dump → llms.txt works immediately!  │
├─────────────────────────────────────────────────────────────┤
│ Opt-in: Runtime Sync (for dynamic content)                  │
│   Cold start → restore dump → sitemap seeder → poll        │
│   Cron (optional) → background re-indexing of stale pages  │
└─────────────────────────────────────────────────────────────┘
```

## [Enabling Runtime Sync](#enabling-runtime-sync)

nuxt.config.ts

```
export default defineNuxtConfig({
  aiReady: {
    runtimeSync: {
      ttl: 3600, // Re-index pages & refresh sitemap older than 1 hour
      batchSize: 20, // Pages per batch
      pruneTtl: 0 // Prune routes not in sitemap (0 = never)
    },
    cron: true // Optional: scheduled background indexing (every minute)
  }
})
```

The module auto-generates a `runtimeSyncSecret` when you enable `runtimeSync` or `cron`. Set `NUXT_AI_READY_RUNTIME_SYNC_SECRET` env var to use your own.

## [Control Endpoints](#control-endpoints)

When you enable `runtimeSync`, these endpoints become available:

```
# Check indexing progress
GET /__ai-ready/status
# Returns: { total: 50, indexed: 45, pending: 5 }

# Trigger batch indexing (requires Authorization: Bearer <token> header if secret configured)
POST /__ai-ready/poll
# Returns: { indexed: 20, remaining: 25, errors: [], duration: 1234, complete: false }

# Process all pending pages (with timeout)
POST /__ai-ready/poll?all=true&timeout=30000
# Returns: { indexed: 45, remaining: 0, errors: [], duration: 28500, complete: true }

# Prune stale routes (dry run - preview what would be pruned)
POST /__ai-ready/prune?dry=true&ttl=604800
# Returns: { routes: ["/old-page"], count: 1, ttl: 604800, dry: true }

# Prune stale routes (execute, requires Authorization: Bearer <token> header)
POST /__ai-ready/prune?ttl=604800
# Returns: { pruned: 1, ttl: 604800, dry: false }
```

You must provide the `Authorization: Bearer<token>` header for POST endpoints if you configure `runtimeSyncSecret`.

### [Poll Endpoint Options](#poll-endpoint-options)

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| `limit` | `number` | `10` | Max pages per batch (max: 50) |
| `all` | `boolean` | `false` | Process until complete |
| `timeout` | `number` | `30000` | Max ms for `all` mode |

### [Prune Endpoint Options](#prune-endpoint-options)

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| `dry` | `boolean` | `false` | Preview stale routes without deleting |
| `ttl` | `number` | `pruneTtl` config | Prune routes older than this (seconds) |
| `secret` | `string` | - | Auth token (required unless dry run) |

## [Scheduled Indexing](#scheduled-indexing)

When you set `cron: true`, Nitro scheduled tasks enable automatic background indexing (runs every minute):

nuxt.config.ts

```
export default defineNuxtConfig({
  aiReady: {
    cron: true // Runs every minute, auto-enables runtimeSync
  }
})
```

The module auto-enables `nitro.experimental.tasks` when you configure cron.

**Cloudflare Workers**: Cron triggers are auto-configured in wrangler.toml.**Cloudflare Pages**: Does not support cron triggers. Use an external scheduler to call `GET /__ai-ready/cron` with `Authorization: Bearer<token>` header. See the [Cloudflare guide](https://nuxtseo.com/docs/ai-ready/guides/cloudflare#cloudflare-pages) for details.

## [TTL Configuration](#ttl-configuration)

| Option | Default | Description |
| --- | --- | --- |
| `ttl` | `3600` | Re-index pages & refresh sitemap older than this (seconds) |
| `pruneTtl` | `0` | Delete routes not in sitemap for this long (0 = never) |

Force re-index regardless of TTL:

```
await indexPage('/about', html, { force: true })
```

## [Database Configuration](#database-configuration)

The module uses [SQLite](https://sqlite.org) via [db0](https://db0.unjs.io/) for cross-platform support. It auto-detects the best connector:

| Runtime | Connector |
| --- | --- |
| [Bun](https://bun.sh) | `bun:sqlite` |
| [Node.js](https://nodejs.org) 22.5+ | `node:sqlite` |
| Node.js <22.5 | `better-sqlite3` |

For edge deployments, configure D1 or LibSQL:

Cloudflare D1

Turso/LibSQL

```
export default defineNuxtConfig({
  aiReady: {
    database: {
      type: 'd1',
      bindingName: 'AI_READY_DB'
    }
  }
})
```

```
export default defineNuxtConfig({
  aiReady: {
    database: {
      type: 'libsql',
      url: process.env.TURSO_URL,
      authToken: process.env.TURSO_AUTH_TOKEN
    }
  }
})
```

## [Serverless Cold Starts](#serverless-cold-starts)

For serverless platforms (Vercel, [Netlify](https://netlify.com), Lambda), the database is ephemeral. The module handles this by:

1. **Build time**: Creates SQLite database and compresses it to `__ai-ready/pages.dump`
2. **Cold start**: `db-restore` plugin decompresses dump and imports into fresh database
3. **Runtime** (if enabled): New pages indexed via sitemap seeder

Prerendered pages are always available, even on cold starts.

## [Sync with External Systems](#sync-with-external-systems)

Use the `ai-ready:page:indexed` hook to sync with vector databases, search indexes, or analytics:

server/plugins/embeddings.ts

```
export default defineNitroPlugin((nitro) => {
  nitro.hooks.hook('ai-ready:page:indexed', async (ctx) => {
    // Generate embeddings for vector search
    const embedding = await openai.embeddings.create({
      model: 'text-embedding-3-small',
      input: ctx.markdown
    })

    await vectorDb.upsert({
      id: ctx.route,
      vector: embedding.data[0].embedding,
      metadata: {
        title: ctx.title,
        description: ctx.description,
        route: ctx.route
      }
    })

    console.log(\`Indexed ${ctx.route} (update: ${ctx.isUpdate})\`)
  })
})
```

## [Manual Indexing](#manual-indexing)

Trigger indexing from API routes or plugins:

server/api/reindex.post.ts

```
import { indexPageByRoute } from '#ai-ready'

export default defineEventHandler(async (event) => {
  const { paths } = await readBody(event)

  const results = await Promise.all(
    paths.map((path: string) =>
      indexPageByRoute(path, event, { force: true })
    )
  )

  return {
    indexed: results.filter(r => r.success && !r.skipped).length,
    skipped: results.filter(r => r.skipped).length,
    failed: results.filter(r => !r.success).length
  }
})
```

## [Direct Database Access](#direct-database-access)

For advanced use cases, access the database directly:

server/api/search.ts

```
import { searchPages, useDatabase } from '#ai-ready'

export default defineEventHandler(async (event) => {
  const { q } = getQuery(event)

  // FTS5 full-text search
  const results = await searchPages(event, q as string, { limit: 10 })

  return results
})
```

Available query functions:

| Function | Description |
| --- | --- |
| `queryPages(event, opts)` | Query pages with filters/pagination |
| `searchPages(event, query, opts)` | FTS5 full-text search |
| `countPages(event, opts)` | Count pages matching criteria |
| `streamPages(event, opts)` | Stream pages for large datasets |
| `upsertPage(event, page)` | Insert or update a page |

## [IndexNow Integration](#indexnow-integration)

Combine runtime sync with [IndexNow](https://nuxtseo.com/docs/ai-ready/guides/indexnow) to notify search engines instantly when pages change. When you enable both `runtimeSync.cron` and `indexNow`, IndexNow syncs automatically after each scheduled indexing run.

## [CLI](#cli)

Use the `nuxt-ai-ready` CLI to interact with control endpoints:

```
# Check indexing status
npx nuxt-ai-ready status

# Trigger batch indexing
npx nuxt-ai-ready poll

# Process all pending pages
npx nuxt-ai-ready poll --all

# Preview stale routes (dry run)
npx nuxt-ai-ready prune --dry

# Prune stale routes
npx nuxt-ai-ready prune --ttl 604800
```

The CLI auto-authenticates using the generated secret. See the [CLI guide](https://nuxtseo.com/docs/ai-ready/guides/cli) for all commands and options.

[Edit this page](https://github.com/nuxt-seo-pro/nuxt-ai-ready/edit/main/docs/content/2.guides/4.runtime-indexing.md)

[Markdown For LLMs](https://nuxtseo.com/docs/ai-ready/guides/runtime-indexing.md)

Did this page help you?

### Related

[CLI](https://nuxtseo.com/docs/ai-ready/guides/cli) [Configuration](https://nuxtseo.com/docs/ai-ready/api/config) [Composables](https://nuxtseo.com/docs/ai-ready/nitro-api/composables) [Nitro Hooks](https://nuxtseo.com/docs/ai-ready/nitro-api/nitro-hooks)

[Model Context Protocol (MCP) Connect AI agents like Claude to your Nuxt site via MCP servers with built-in tools and resources.](https://nuxtseo.com/docs/ai-ready/guides/mcp) [Cloudflare Deployment Deploy with Cloudflare D1 for persistent database storage.](https://nuxtseo.com/docs/ai-ready/guides/cloudflare)

On this page

- [When You Need Runtime Sync](#when-you-need-runtime-sync)
- [How It Works](#how-it-works)
- [Enabling Runtime Sync](#enabling-runtime-sync)
- [Control Endpoints](#control-endpoints)
- [Scheduled Indexing](#scheduled-indexing)
- [TTL Configuration](#ttl-configuration)
- [Database Configuration](#database-configuration)
- [Serverless Cold Starts](#serverless-cold-starts)
- [Sync with External Systems](#sync-with-external-systems)
- [Manual Indexing](#manual-indexing)
- [Direct Database Access](#direct-database-access)
- [IndexNow Integration](#indexnow-integration)
- [CLI](#cli)

[GitHub](https://github.com/harlan-zw/nuxt-seo) [ Discord](https://discord.com/invite/275MBUBvgP)

### [NuxtSEO](https://nuxtseo.com/ "Home")

- [Getting Started](https://nuxtseo.com/docs/nuxt-seo/getting-started/introduction)
- [MCP](https://nuxtseo.com/docs/nuxt-seo/guides/mcp)

Modules

- [Robots](https://nuxtseo.com/docs/robots/getting-started/introduction)
- [Sitemap](https://nuxtseo.com/docs/sitemap/getting-started/introduction)
- [OG Image](https://nuxtseo.com/docs/og-image/getting-started/introduction)
- [Schema.org](https://nuxtseo.com/docs/schema-org/getting-started/introduction)
- [Link Checker](https://nuxtseo.com/docs/link-checker/getting-started/introduction)
- [SEO Utils](https://nuxtseo.com/docs/seo-utils/getting-started/introduction)
- [Site Config](https://nuxtseo.com/docs/site-config/getting-started/introduction)
- [Skew Protection](https://nuxtseo.com/docs/skew-protection/getting-started/introduction)
- [AI Ready](https://nuxtseo.com/docs/ai-ready/getting-started/introduction)

### [NuxtSEO Pro](https://nuxtseo.com/pro "Nuxt SEO Pro")

- [Getting Started](https://nuxtseo.com/pro)
- [Dashboard](https://nuxtseo.com/pro/dashboard)
- [Pro MCP](https://nuxtseo.com/pro/docs/getting-started/mcp-setup)

### [Learn SEO](https://nuxtseo.com/learn-seo "Learn SEO")

Nuxt

- [Mastering Meta](https://nuxtseo.com/learn-seo/nuxt/mastering-meta)
- [Controlling Crawlers](https://nuxtseo.com/learn-seo/nuxt/controlling-crawlers)
- [Launch & Listen](https://nuxtseo.com/learn-seo/nuxt/launch-and-listen)
- [Routes & Rendering](https://nuxtseo.com/learn-seo/nuxt/routes-and-rendering)
- [Staying Secure](https://nuxtseo.com/learn-seo/nuxt/routes-and-rendering/security)

Vue

- [Vue SEO Guide](https://nuxtseo.com/learn-seo/vue)
- [Mastering Meta](https://nuxtseo.com/learn-seo/vue/mastering-meta)
- [Controlling Crawlers](https://nuxtseo.com/learn-seo/vue/controlling-crawlers)
- [SPA SEO](https://nuxtseo.com/learn-seo/vue/spa)
- [SSR Frameworks](https://nuxtseo.com/learn-seo/vue/ssr-frameworks)
- [SEO Checklist](https://nuxtseo.com/learn-seo/checklist)
- [Pre-Launch Warmup](https://nuxtseo.com/learn-seo/pre-launch-warmup)
- [Backlinks & Authority](https://nuxtseo.com/learn-seo/backlinks)

### [Tools](https://nuxtseo.com/tools "SEO Tools")

- [Social Share Debugger](https://nuxtseo.com/tools/social-share-debugger)
- [Robots.txt Generator](https://nuxtseo.com/tools/robots-txt-generator)
- [Meta Tag Checker](https://nuxtseo.com/tools/meta-tag-checker)
- [HTML to Markdown](https://nuxtseo.com/tools/html-to-markdown)
- [XML Sitemap Validator](https://nuxtseo.com/tools/xml-sitemap-validator)
- [Schema.org Validator](https://nuxtseo.com/tools/schema-validator)
- [Keyword Idea Generator](https://nuxtseo.com/tools/keyword-generator)
- [Keyword Research](https://nuxtseo.com/tools/keyword-research)
- [SERP Analyzer](https://nuxtseo.com/tools/serp-analyzer)
- [Domain Rankings](https://nuxtseo.com/tools/domain-rankings)

Copyright © 2023-2026 Harlan Wilton - [MIT License](https://github.com/harlan-zw/nuxt-seo/blob/main/license) · [mdream](https://mdream.dev)