docus-cloudflare-ai-search

Replace Docus default search with Cloudflare AI Search

1
0
1
11
TypeScript
public

docus-cloudflare-ai-search

npm version
npm downloads
License
Nuxt
pkg.pr.new

Replace the default Docus search with Cloudflare AI Search. Read Bringing Cloudflare AI Search to Docus and VitePress for the story behind the package family.

  • Replaces only the Docus AppSearch component.
  • Queries a public Cloudflare AI Search endpoint from the browser.
  • Keeps the command palette, navigation browsing, keyboard shortcut, and result routing.
  • Stores the five most recently selected results in local storage.

Installation

pnpm add docus-cloudflare-ai-search

Usage

Add the module after Docus and provide the public AI Search endpoint root:

// nuxt.config.ts
export default defineNuxtConfig({
  extends: ['docus'],
  modules: ['docus-cloudflare-ai-search'],
  aiSearch: {
    client: {
      enabled: true,
      endpoint: 'https://search.example.com',
    },
  },
})

When enabled, the module registers a Docus AppSearch replacement. Disable it or omit enabled to retain Docus’s default search. An app/components/AppSearch.vue in your application can still override the module component.

The endpoint is required when the client is enabled. Use the public Cloudflare AI Search endpoint root without /search; the module appends that path to browser requests.

Options

export default defineNuxtConfig({
  aiSearch: {
    ui: {
      placeholder: 'Search documentation',
      messages: {
        empty: 'No results found.',
        error: 'Search is temporarily unavailable. Please try again.',
        rateLimit: 'Too many searches. Please try again shortly.',
        recent: 'Recent AI searches',
      },
    },
    client: {
      enabled: true,
      endpoint: 'https://search.example.com',
      debounceMs: 200,
      query: {
        minLength: 2,
        maxLength: 200,
      },
      request: {
        timeoutMs: 8_000,
        retrievalOptions: {
          max_num_results: 10,
        },
      },
    },
  },
})
Option Description
client.enabled Enables the Docus AppSearch override. Defaults to false.
client.endpoint Required when enabled. Public Cloudflare AI Search endpoint root.
client.debounceMs Delay before sending a search request. Defaults to 200.
client.query.minLength, client.query.maxLength Browser query-length limits. Overlong queries are truncated.
client.request.timeoutMs Browser request timeout in milliseconds.
client.request.retrievalOptions Public retrieval and reranking options sent as ai_search_options. Defaults to { max_num_results: 10 }.
ui.placeholder Command-palette input placeholder.
ui.messages Labels for empty, failed, rate-limited, and recent search states.

[!WARNING]
The endpoint and every client option are sent to the browser. Never include API tokens, Authorization values, Cloudflare Access service-token secrets, or other credentials.

Cloudflare setup

Create an AI Search instance, enable its public /search endpoint, and add your development and production origins to its authorized hosts. Index only content that is safe to expose publicly.

Use cloudflare-ai-search-sync to index Nuxt Content during builds.

Sponsors

Sponsors

License

MIT License © 2026-PRESENT Estéban Soubiran

v0.3.3[beta]