VitePress adds every head entry in its site config to every page. You add the widget there.

Before you start

  • A website widget with your site on its Allowed origins list. You need the widget id and public key from its snippet.

Add the widget

1

Open the site config

It is .vitepress/config.ts, or config.mts / config.js.
2

Add a script entry to head

Add this inside defineConfig({ ... }). If head already exists, add the entry to it.
.vitepress/config.ts
head: [
  [
    "script",
    {
      async: "",
      src: "https://widget.kelu.dev/kelu-widget.js",
      "data-widget-id": "YOUR_WIDGET_ID",
      "data-client-key": "kl_pk_...",
    },
  ],
],
Replace YOUR_WIDGET_ID and kl_pk_... with the values from your widget’s snippet. async: "" writes the async attribute with no value.
3

Check locally, then deploy

Run npm run docs:dev to see it locally, then build and deploy your site as usual.

Check it works

Open any page. A round Ask AI button appears in the bottom-right corner. Ask a question and check that the answer lists its Sources. Nothing there? See Troubleshooting.
If your site search opens with Cmd+K, turn off Open with Cmd/Ctrl+K on the widget’s Behaviour tab so only one opens. To follow VitePress’s dark mode, set Dark-mode selector to html.dark on the Appearance tab.