JavaScript SDK
Framework-agnostic SDK for any JavaScript environment
What is 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 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 set it up
Install: npm install @beforequery/sdk
Initialize the client with your client key: const bq = new BeforeQueryClient({ clientKey: 'bq_pk_...' })
Call bq.chat() for streaming RAG 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.
A per-project MCP server at api.beforequery.com/mcp/projects/:projectId lets any MCP-aware AI tool query your knowledge base as structured tools.
Ready to connect JavaScript SDK?
Start free. No credit card required. Connect your first integration in under 5 minutes.