VitePress offers two clean ways to inject the widget: a head entry in the site config (simplest), or the enhanceApp hook in your theme if you need runtime control.
1

Open .vitepress/config.ts (or .js)

Open .vitepress/config.ts (or config.mts / config.js) at the root of your VitePress project.
2

Add to the head array

Add a script entry to the head array in your defineConfig call:
.vitepress/config.ts
VitePress head entries are tuples of [tag, attrs, innerHTML?]. The async attribute is boolean — pass an empty string "" to emit it without a value.Replace kb_xxx and bq_pk_... with your actual values.
3

Run the dev server

Run npm run docs:dev (or vitepress dev). Inspect the rendered <head> to confirm the tag is present and verify the launcher appears on the page.
Get your keys — your knowledge base ID and public client key (bq_pk_...) are in the BeforeQuery dashboard under Knowledge Base → Integration. Add your VitePress site’s domain to the key’s origin allowlist.
For all widget configuration options, see Widget reference.