React component

Install with pnpm add @bootstrapware/answers. Import Answers from @bootstrapware/answers and the stylesheet once. The component uses hooks, so it belongs in a client boundary. Non-React pages use the Hosted script embed.

  • presentation defaults to launcher. Also section, modal, and window.
  • defaultOpen opens modal, window, and launcher. They start closed otherwise.
  • theme is optional light or dark. Omit it for the light cream default. The widget does not follow prefers-color-scheme.
  • pageContext is { url, title }. Omit it and the widget sends the current URL and document title. It does not send the DOM.
  • onFallback runs for an unanswered result. The widget does not render an answer body for that outcome.
  • suggestedQuestions is a list of starter questions. Each one is a chip. Choosing a chip asks that question.
  • shortcut opens the widget and focuses the question field. mod+k is Command on macOS and Control elsewhere.

Pass appId and publishableKey with no adapter and the component calls Hosted POST /api/v1/ask. createHostedAdapter is the same client if you want to build it yourself. Optional apiBaseUrl defaults to https://answers.bootstrapware.co. A publishable key without an app id does not fetch.

import { Answers } from "@bootstrapware/answers";
import "@bootstrapware/answers/styles.css";

<Answers
  appId="ana_…"
  publishableKey={process.env.NEXT_PUBLIC_BSW_ANSWERS_PUBLISHABLE_KEY}
  suggestedQuestions={["What is your return window?", "How much is Hosted?"]}
  shortcut="mod+k"
/>

Related: Modes · React guide