JavaScript SDK AI Integration
Framework-agnostic SDK for any JavaScript environment
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.
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.
How to connect JavaScript SDK
- Step 01
Install: npm install @beforequery/sdk
- Step 02
Initialize the client with your client key: const bq = new BeforeQueryClient({ clientKey: 'bq_pk_...' })
- Step 03
Call bq.chat() for streaming grounded answers or bq.search() for hybrid search results.
Related integrations
The BeforeQuery web widget embeds in any HTML page. One script tag, full style customization, mobile-ready, WCAG AA accessible.
Install @beforequery/react for a <BeforeQueryChat /> drop-in or the useBeforeQueryChat headless hook for a fully custom UI.
An MCP server at api.beforequery.com/mcp, scoped to a knowledge base by its client key, lets any MCP-aware AI tool query your knowledge base as structured tools.
JavaScript SDK — Frequently Asked Questions
Common questions about connecting BeforeQuery to JavaScript SDK.
Ready to connect JavaScript SDK?
Start free. No credit card required. Connect your first integration in under 5 minutes.