GitBook has no custom-script field. There is no setting, on any plan, that injects a <script> tag into a published GitBook site — so the widget cannot be installed the way it is on every other platform.GitBook’s developer documentation is explicit: the site:script:inject scope “is only available for internal GitBook use,” and “building integrations that inject JavaScript into a site or space is not possible at this time.” A third party cannot ship a GitBook integration that loads the widget.
Everything else in BeforeQuery works normally with GitBook. Only the in-page widget is blocked, and only on GitBook’s own hosting.

Index the content

Crawling is unaffected — GitBook publishes ordinary HTML. Add a website source pointing at your GitBook domain (yourproduct.gitbook.io or your custom domain). Pages index, chunk, embed and cite exactly as any other docs site, and every answer links back to the GitBook page it came from.

Put the assistant where you do control the markup

Your GitBook content is answerable from any surface that does not need a script on GitBook’s pages:

Your app or marketing site

The same widget, embedded where you own the HTML. It answers from the GitBook content and links back to it.

Slack, Discord, Teams

Readers ask in the channel they are already in. No docs-site change at all.

MCP server

Cursor, Claude and other MCP clients search the docs directly.

Browser extension

A side panel that answers on any page, including GitBook’s.

Advanced: inject at the edge

If your GitBook site is served through a custom domain that you proxy — a Cloudflare-proxied CNAME rather than a direct one — you can add the script in transit instead of at the origin. A Cloudflare Worker using HTMLRewriter appends it to every response:
worker.js
This requires the domain to route through your proxy — it does not apply to *.gitbook.io addresses, and it is your infrastructure to operate, not GitBook’s. Treat it as a real option only if you already terminate that domain.
Get your keys — your knowledge base ID and public client key (bq_pk_...) are in the BeforeQuery dashboard under Knowledge Base → Integration. Add whichever domain ends up serving the widget to the key’s origin allowlist.
For all widget configuration options, see Widget reference.