@beforequery/react gives you two ways to put your assistant inside a React app:
  • <BeforeQueryChat /> — a polished, self-contained chat panel: streaming answers, numbered source citations, thread continuity, error states, and thumbs up/down feedback, all built in.
  • useBeforeQueryChat — a headless hook that manages streaming, state, and errors while you own every pixel of the UI.

Set up the component

1

Install the packages

react and react-dom (>= 18) are peer dependencies.
2

Get a client key

In the dashboard at app.beforequery.com, open Project → Integration Credentials and create a public client key (bq_pk_…). Public keys are safe to ship in browsers — they’re scoped to one project and support an origin allowlist. Copy the key and your project ID.
3

Embed the chat panel

Run your app and ask a question — you should see a streamed answer with Sources citations and feedback buttons under each reply.
4

Customize the look

Match your brand with the theme prop, and tune the copy:

Component props

Build your own UI with the hook

When the prebuilt panel doesn’t fit, useBeforeQueryChat gives you the same streaming machinery with none of the styling:
The hook returns messages, ask(query), isStreaming, error, threadId, reset(), and sendFeedback(). Follow-up questions automatically continue the same thread — call reset() to start over.

Collect feedback

Assistant messages carry a server-assigned messageId once streaming completes — use it to record ratings (1–5):
Ratings feed knowledge-gap analytics, so every thumbs-down helps you find what to document next.

Test against a local backend

Point the component (or hook) at a locally running API with baseUrl:

Troubleshooting

  • 401/403 errors — check the client key belongs to the same project as projectId, and that your page’s origin is on the key’s allowlist.
  • Captcha errors — if your project enforces reCAPTCHA, pass getCaptchaToken returning a fresh v3 token per request.
See the full @beforequery/react reference for hook types and advanced usage.