Cloudflare Deployment
Attach a D1 database to keep indexed pages across Cloudflare requests and deployments. This guide assumes you already have a Nuxt deployment on Workers or Pages.
Setup
1. Create D1 Database
npx wrangler d1 create ai-ready-dbCopy the database ID from the command output:
Created D1 database: ai-ready-db
Database ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx2. Configure wrangler.toml
Add this binding to your deployment’s Wrangler configuration. Keep its existing entry point and compatibility settings.
If Nitro generates that file, add the binding through nitro.cloudflare.wrangler.d1_databases in Nuxt config instead.
Use the same binding name in the module configuration. See Cloudflare’s D1 binding guide.
[[d1_databases]]
binding = "AI_READY_DB"
database_name = "ai-ready-db"
database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"3. Configure Module
The database needs drizzle-orm, an optional peer dependency. Install it:
npx nypm add drizzle-orm@1.0.0-rc.4Then select D1:
export default defineNuxtConfig({
aiReady: {
database: {
type: 'd1',
bindingName: 'AI_READY_DB'
}
}
})How It Works
Prerendering prepares __ai-ready/pages.dump during the build. An empty runtime database restores that dump into D1.
D1 keeps the data across requests.
On a new build, the module compares content hashes. It adds new pages and marks changed pages for indexing.
Enable runtime sync with poll or cron to process pending pages.
For edits to existing pages between builds, call the reindex endpoint. There is no automatic page indexing in an afterResponse hook.
NuxtHub
If you use NuxtHub, check the D1 binding created by your installed version.
Set aiReady.database.bindingName to that binding. Current NuxtHub database configuration uses hub.db.
Nuxt AI Ready does not provision a D1 database itself. Keep the binding configuration in your deployment setup.
Scheduled Tasks (Cron)
Cloudflare Workers supports native cron triggers, but Cloudflare Pages does not.
Cloudflare Workers
When deploying to Cloudflare Workers with cron: true, the module adds cron triggers to Nitro’s generated Wrangler configuration:
export default defineNuxtConfig({
aiReady: {
cron: true
}
})Cloudflare Pages
Cloudflare Pages cannot run native cron triggers. Set cron: true to expose the production HTTP endpoint, then call it externally:
export default defineNuxtConfig({
aiReady: {
cron: true
}
})Bind NUXT_APP_SECRET as an encrypted Worker or Pages secret, with at least 32 characters.
Use the same root secret as OG Image. AI Ready reads the request's binding, including runtime-only values and rotations.
The legacy runtimeSyncSecret option and module-specific secret bindings remain supported with a deprecation warning.
Both NUXT_AI_READY_RUNTIME_SYNC_SECRET and NUXT_NUXT_AI_READY_RUNTIME_SYNC_SECRET bindings work.
Without an application secret, send the legacy token unchanged. A non-empty application secret takes precedence.
For an external scheduler, run pnpm exec nuxt-ai-ready token with that root secret in your environment.
Store its output as the scheduler's bearer token. You can also derive it in an installed project's GitHub Actions job:
name: AI Ready Sync
on:
schedule:
- cron: '*/5 * * * *' # every 5 minutes
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/setup@v2
with:
runtime: node@lts
- run: pnpm install --frozen-lockfile
- name: Refresh indexed pages
env:
SITE_URL: ${{ secrets.SITE_URL }}
NUXT_APP_SECRET: ${{ secrets.NUXT_APP_SECRET }}
run: >
curl --fail-with-body
-H "Authorization: Bearer $(pnpm exec nuxt-ai-ready token)"
"$SITE_URL/__ai-ready/cron"# One-time sync
curl --fail-with-body -H "Authorization: Bearer $(pnpm exec nuxt-ai-ready token)" -X GET "https://yoursite.pages.dev/__ai-ready/cron"
# Restore the build dump, replacing stored page data
curl --fail-with-body -H "Authorization: Bearer $(pnpm exec nuxt-ai-ready token)" -X POST "https://yoursite.pages.dev/__ai-ready/restore"The production cron endpoint restores the dump when needed, seeds sitemap routes, and indexes pending pages. The scheduler must use the derived token for the deployed app's current root secret. Native scheduled tasks need no HTTP bearer token. The cron route is absent during development.
Notes
- Build time: Always uses SQLite (D1 not available during build)
- Local dev: Query helpers do not expose runtime indexed data. Test a built server or your platform preview.
- FTS5: D1 fully supports FTS5 full-text search
- Pages cron: Use external scheduler to call
/__ai-ready/cron