JavaScript SDK logo
Embed & Developer

JavaScript SDK AI Integration

Framework-agnostic SDK for any JavaScript environment

What is it?

About JavaScript SDK

The @beforequery/sdk package is the core BeforeQuery client library. It works in any JavaScript environment: browser, Node.js, React Native, Deno, and edge runtimes. The React package is built on top of this SDK. Use it directly when you need maximum control or when your stack is not React-based.

Integration capabilities

How BeforeQuery works with JavaScript SDK

Everything you can do once the JavaScript SDK integration is connected.

Universal environment support

Works in browser, Node.js, React Native, and edge runtimes (Cloudflare Workers, Deno Deploy, Vercel Edge). One package, all environments.

Search and Chat APIs

The SDK wraps BeforeQuery's search (hybrid vector + full-text) and chat (SSE streaming RAG) endpoints with a clean, typed API.

Public and server-side auth

Use public client keys (bq_pk_...) for browser-side code and client ID + secret (bq_ci_... / bq_cs_...) for server-side integrations.

Streaming response support

The SDK handles SSE stream parsing and provides an async iterator for streaming chat responses in any JavaScript environment.

Setup

How to connect JavaScript SDK

  1. Step 01

    Install: npm install @beforequery/sdk

  2. Step 02

    Initialize the client with your client key: const bq = new BeforeQueryClient({ clientKey: 'bq_pk_...' })

  3. Step 03

    Call bq.chat() for streaming grounded answers or bq.search() for hybrid search results.

JavaScript SDK — Frequently Asked Questions

Common questions about connecting BeforeQuery to JavaScript SDK.

Yes. @beforequery/sdk is built to run in edge runtimes including Cloudflare Workers, Vercel Edge Functions, and Deno Deploy. It uses the standard Fetch API and avoids Node.js-specific APIs, making it compatible with any edge runtime that supports Fetch.
Install @beforequery/sdk and initialize a BeforeQueryClient with your knowledge base's client key. Call bq.chat() for streaming grounded answers or bq.search() for hybrid search results. The SDK is framework-agnostic — you manage the UI reactive state using your framework's primitives (Vue refs, Svelte stores, etc.).
The SDK parses Server-Sent Events (SSE) from the BeforeQuery Chat API and exposes an async iterator. You iterate over the stream to receive token chunks in real time and assemble the final answer with the source shown when the stream closes.
Public client keys (bq_pk_...) are for browser-side and client-side use — they grant read-only access and are safe to expose in public pages. Client ID plus secret (bq_ci_... / bq_cs_...) pairs are for server-side integrations where the secret must never be exposed to the browser.
@beforequery/sdk is the core client library. @beforequery/react is a React wrapper built on top of it that provides the <BeforeQueryChat /> component and useBeforeQueryChat hook. If you are building a React app, prefer @beforequery/react. For Vue, Svelte, React Native, Node.js, or raw API access, use @beforequery/sdk directly.

Ready to connect JavaScript SDK?

Start free. No credit card required. Connect your first integration in under 5 minutes.