SDK overview
Complete reference for PolynomialHQ's browser, React, server, and protocol packages.
SDKs
@polynomialhq/react
Providers and hooks for collaborative React interfaces. Start here.
@polynomialhq/client
Framework-agnostic rooms, presence, events, storage, and the connection layer.
@polynomialhq/server
Room tokens, identity tokens, room management, and server-side broadcasts.
@polynomialhq/contracts
Zod schemas and codecs for the versioned WebSocket protocol.
| Package | Primary entry point | Runtime |
|---|---|---|
@polynomialhq/client | createClient() | Browser, or a runtime with WebSocket and fetch |
@polynomialhq/react | PolynomialProvider | Browser, React 18.2+ |
@polynomialhq/server | new PolynomialServer() | Node.js only — uses node:crypto |
@polynomialhq/contracts | clientWebSocketMessageSchema | Anywhere |
All packages are ESM, include TypeScript declarations, and publish a single root export.
How they stack
@polynomialhq/react depends on @polynomialhq/client, which depends on
@polynomialhq/contracts. Installing the React package brings the whole browser stack, and it
re-exports createClient so most applications never import the client package by name.
@polynomialhq/server is independent: it shares no code with the browser packages and speaks HTTP
plus token signing rather than the WebSocket protocol.
Which layer should I use?
- Start with
@polynomialhq/reactfor a React interface. - Use
@polynomialhq/clientfor another view framework, a state adapter, or direct room access. - Use
@polynomialhq/serverfor every operation involving ask_...secret. - Use
@polynomialhq/contractsonly when implementing a protocol adapter, worker, or raw WebSocket integration.