Algolia

Replace the built-in search with Algolia DocSearch, and add Ask AI in its own side panel.

Algolia DocSearch searches an index that Algolia's crawler builds from your published site. The official plugin @docubook/plugin-search-algolia swaps Flame's built-in search for DocSearch v5 and, if you give it an Agent Studio agent, adds Ask AI.

The two stay apart. Search opens the DocSearch dialog and shows search results only. Ask AI opens a separate side panel beside the page, so a question never shows up in the search dialog and a search never starts a chat.

Install

bash
npm install -D @docubook/plugin-search-algolia

Register it in the plugins array of docu.json:

docu.json
{
  "plugins": [
    ["@docubook/plugin-search-algolia", {
      "appId": "YOUR_APP_ID",
      "apiKey": "YOUR_SEARCH_ONLY_API_KEY",
      "indexName": "YOUR_INDEX_NAME",
      "askAi": "YOUR_AGENT_ID"
    }]
  ]
}

Leave out askAi to ship search without Ask AI. Remove the plugin entry to go back to the built-in search.

Where it appears

PlaceSearchAsk AI
Desktop sidebarThe search bar under the logoA Sparkles button beside the search bar
Mobile barThe search icon—
Mobile menu drawer—An Ask AI button under the GitHub icon and theme toggle
Keyboard⌘ K / Ctrl K⌘ I / Ctrl I (toggles the panel)

The dialog and the panel follow your theme colors and the light/dark toggle. Opening one closes the other, and closing them returns focus to where you were.

The DocSearch code loads the first time a reader hovers, focuses or clicks search or Ask AI, so pages that nobody searches from do not download it. The files are copied next to Flame's own bundles and served from your domain, so the site's script-src 'self' policy needs no change.

Options

OptionTypeDescription
appIdstringRequired. Algolia application ID.
apiKeystringRequired. Search-only API key.
indexNamestringRequired. Index the crawler writes to.
askAistring | objectAgent ID, or the Ask AI options below. Omit for search only.
searchParametersobjectAlgolia search parameters for the dialog, e.g. { "facetFilters": ["lang:en"] }.
placeholderstringPlaceholder of the search input.
maxResultsPerGroupnumberMaximum results per group in the dialog.
disableUserPersonalizationbooleanDo not keep recent and favorite searches in local storage.
translationsobjectDocSearch modal translations.
relativeUrlsbooleanDefault true: results open on the site you are on, not the crawled domain, so search also works in flame dev and on preview deployments.

Options are checked when the build starts. A missing or malformed value stops the build with a [plugin:search-algolia] error naming the option.

Ask AI

Ask AI needs an agent in Algolia Agent Studio with your index as its search tool. Pass its ID as a string, or pass an object to tune the panel:

docu.json
["@docubook/plugin-search-algolia", {
  "appId": "YOUR_APP_ID",
  "apiKey": "YOUR_SEARCH_ONLY_API_KEY",
  "indexName": "YOUR_INDEX_NAME",
  "askAi": {
    "agentId": "YOUR_AGENT_ID",
    "suggestedQuestions": true,
    "side": "right",
    "width": 400
  }
}]
OptionTypeDescription
agentIdstringRequired. Agent Studio agent ID.
appId / apiKeystringCredentials of the agent, when they differ from the search ones.
indicesstring[]Indices sent with each question. Only for an agent whose search tool is in dynamic mode. A static tool rejects them, so leave this out to use the indices configured on the agent.
searchParametersobjectSearch parameters per index name, e.g. { "YOUR_INDEX_NAME": { "distinct": false } }.
suggestedQuestionsbooleanShow suggested questions when a conversation starts.
variant"floating" | "inline"Fallback presentation for hosts without split-workspace support. On current Flame, the desktop panel always docks beside the document box.
side"left" | "right"Side the panel opens from. Default right.
width / expandedWidthnumber | stringPreferred desktop width in pixels or any CSS width. Defaults: 360px and 580px, clamped to leave room for the document.
translationsobjectDocSearch Sidepanel translations.

Register for DocSearch

Algolia provides DocSearch for open-source projects for free.

  1. Visit the DocSearch application

    Go to docsearch.algolia.com/apply and submit your documentation URL.

  2. Wait for approval

    Algolia reviews your application and sends your credentials:

    • Application ID
    • Search-Only API Key
    • Index Name
  3. Add the plugin to docu.json

    Add the plugin entry as shown in Install. No .env file needed. For Ask AI, create an agent in Agent Studio and add its ID as askAi.

Crawler Setup

After your site is live, configure the Algolia crawler to index your pages. The crawler runs externally on Algolia's infrastructure — no build-time impact on Flame.

Dashboard Setup

  1. Open Algolia Dashboard
  2. Navigate to Crawler

    Go to Data Sources → Crawler → click your crawler name.

  3. Add and verify your domain

    In the Domains tab, add your production URL. If Algolia asks you to verify it, open the Meta tag tab, copy the code from content="…", and add it to docu.json:

    json
    {
      "meta": {
        "verification": {
          "algolia-site-verification": "YOUR_VERIFICATION_CODE"
        }
      }
    }
    

    Flame writes <meta name="algolia-site-verification" content="YOUR_VERIFICATION_CODE"> into every page it builds, including the home page. Deploy, then click Verify now next to the domain. See Site verification.

  4. Open the Editor

    Open the Setup dropdown → select Editor.

Crawler Configuration

Paste the configuration below into the editor. The values you need to change are highlighted.

index.js
new Crawler({
  appId: "YOUR_APP_ID",           // ← your App ID
  apiKey: "YOUR_CRAWLER_API_KEY",  // ← your crawler API key
  indexPrefix: "",
  rateLimit: 8,
  startUrls: ["https://your-domain.com"], // ← your domain
  renderJavaScript: false,
  maxDepth: 10,
  maxUrls: 8000,
  schedule: "every 1 day at 02:00 am",
  sitemaps: [],
  ignoreCanonicalTo: true,
  discoveryPatterns: ["https://your-domain.com/**"], // ← your domain
  actions: [
    {
      indexName: "YOUR_INDEX_NAME", // ← your index name
      pathsToMatch: ["https://your-domain.com/**"], // ← your domain
      recordExtractor: ({ $, helpers }) => {
        const lvl0 =
          // lvl0 = section name from breadcrumb (second item: Docs > Section > Page)
          $(".breadcrumbs li:nth-child(2)").text().trim() ||
          "Docs";

        // ids of layout wrappers, not of a section: strip them from record urls
        const layoutAnchors = ["scroll-container", "mdx-content-island"];

        return helpers
          .docsearch({
            recordProps: {
              lvl0: {
                selectors: "",
                defaultValue: lvl0,
              },
              lvl1: [".prose h1"],
              // page description + MDX body only, so "Last updated" and the footer stay out
              content: [".prose > p, #mdx-content-island p, #mdx-content-island li, #mdx-content-island td"],
              lvl2: [".prose h2"],
              lvl3: [".prose h3"],
              lvl4: [".prose h4"],
              lvl5: [".prose h5"],
              lvl6: [".prose h6"],
            },
            aggregateContent: true,
            recordVersion: "v3",
          })
          .map((record) => {
            if (!layoutAnchors.includes(record.anchor)) return record;
            return {
              ...record,
              anchor: undefined,
              url: record.url
                ? record.url.replace(/#(scroll-container|mdx-content-island)$/, "")
                : record.url,
              url_without_anchor:
                record.url_without_anchor ||
                (record.url ? record.url.split("#")[0] : record.url),
            };
          });
      },
    },
  ],
  safetyChecks: { beforeIndexPublishing: { maxLostRecordsPercentage: 10 } },
  initialIndexSettings: {
    "YOUR_INDEX_NAME": {
      attributesForFaceting: ["type", "lang"],
      attributesToRetrieve: [
        "hierarchy", "content", "anchor", "url",
        "url_without_anchor", "type",
      ],
      attributesToHighlight: ["hierarchy", "content"],
      attributesToSnippet: ["content:10"],
      camelCaseAttributes: ["hierarchy", "content"],
      searchableAttributes: [
        "unordered(hierarchy.lvl0)",
        "unordered(hierarchy.lvl1)",
        "unordered(hierarchy.lvl2)",
        "unordered(hierarchy.lvl3)",
        "unordered(hierarchy.lvl4)",
        "unordered(hierarchy.lvl5)",
        "unordered(hierarchy.lvl6)",
        "content",
      ],
      distinct: true,
      attributeForDistinct: "url",
      customRanking: [
        "desc(weight.pageRank)",
        "desc(weight.level)",
        "asc(weight.position)",
      ],
      ranking: [
        "words", "filters", "typo", "attribute",
        "proximity", "exact", "custom",
      ],
      highlightPreTag: '<span class="algolia-docsearch-suggestion--highlight">',
      highlightPostTag: "</span>",
      minWordSizefor1Typo: 3,
      minWordSizefor2Typos: 7,
      allowTyposOnNumericTokens: false,
      minProximity: 1,
      ignorePlurals: true,
      advancedSyntax: true,
      attributeCriteriaComputedByMinProximity: true,
      removeWordsIfNoResults: "allOptional",
    },
  },
});

Index Settings

Key settings worth noting:

SettingValueWhy
distincttrueDeduplicate records by URL — one result per page
attributeForDistinct"url"Group all sections of a page under one result
content#mdx-content-island …Indexes the page description, paragraphs, list items and table cells, but not "Last updated" or the footer
renderJavaScriptfalseFlame writes every page as static HTML, so the crawler needs no browser and crawls faster
scheduleevery 1 dayKeeps search results fresh without over-scraping

Deploy

Credentials live in docu.json, so no .env file or platform secrets are needed. Build and deploy .docu/dist/ to any static host as usual: the plugin writes its browser files into the build output.

The browser needs to reach Algolia over HTTPS. Flame's default connect-src 'self' https: policy already allows it. If you tightened connect-src on your host, allow https://*.algolia.net and https://*.algolianet.com. Ask AI talks to Agent Studio on the same *.algolia.net hosts.

Last updated Nov 7, 2026