Registry / messaging / wse-client

wse-client

JSON →
library2.3.2jsnpmunverified

WSE (WebSocket Engine) React client for the Rust-based WSE server ecosystem. Current stable version 2.3.2, released monthly. Provides type-safe React hooks with auto-reconnect, offline message queue, and E2E encryption via ECDH P-256 + AES-GCM-256. Key differentiators: Rust-accelerated server with zero-GIL data path, pre-framed broadcast, and lock-free state using DashMap; client supports MessagePack binary transport, topic subscriptions, queue groups, and presence tracking. Requires Zustand for state management and natively ships TypeScript definitions.

npm install wse-client
INSTALL
IMPORT
SIG · WSE-CLIENT
W
wse-client
messagingjavascriptv2.3.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

useWSE
import { useWSE } from 'wse-client'
const useWSE = require('wse-client')
ESM-only package since v2.0; CommonJS require() will fail.
WSEProvider
import { WSEProvider } from 'wse-client'
The provider must wrap your component tree to use hooks.
useTopic
import { useTopic } from 'wse-client'
import { useTopic } from 'wse-client/hooks'
All hooks are exported from the main package, not subpaths.
createWSEStore
import { createWSEStore } from 'wse-client'
import createWSEStore from 'wse-client'
Named export, not default.

Shows required provider wrapping, connection status, topic subscription, and message sending.

import { WSEProvider, useWSE, useTopic } from 'wse-client'; import { create } from 'zustand'; function MyComponent() { const { send, connected, reconnect } = useWSE(); const { messages } = useTopic('chat:general'); return ( <div> <p>Status: {connected ? 'connected' : 'disconnected'}</p> <button onClick={() => send({ type: 'message', text: 'Hello!' })}>Send</button> <ul>{messages.map((m, i) => <li key={i}>{m.text}</li>)}</ul> </div> ); } function App() { return ( <WSEProvider url={process.env.WSE_URL ?? 'ws://localhost:8080'} token={process.env.WSE_TOKEN ?? ''}> <MyComponent /> </WSEProvider> ); }
Debug
Known issues
breakingESM-only since v2.0: requires Node >=18 and ES module imports.
fix
Use import statements instead of require().
affects: >=2.0
breakingPeer dependency zustand is required starting v2.0; older versions used internal store.
fix
Add zustand@>=4 to your dependencies.
affects: >=2.0
deprecatedUnencrypted connections are deprecated; server requires encryption by default.
fix
Ensure server enables E2E encryption or set encryption: 'optional' in client options.
affects: >=1.5
gotchaThe useTopic hook must be used within a component wrapped by WSEProvider; otherwise it throws a runtime error.
fix
Wrap your component tree with <WSEProvider>.
affects: >=1.0
gotchasend() in useWSE is not stable by reference; avoid passing it as a dependency to useEffect without memoization.
fix
Wrap send in useCallback or use the stable sendRef from createWSEStore.
affects: >=1.0
Errors
Common errors & fixes
require() of ES Module wse-client not supported
wse-client is ESM-only since v2.0; require() is not supported.
fix
Change to import statements or use dynamic import().
Cannot read properties of undefined (reading 'subscribe')
useTopic called outside WSEProvider context.
fix
Ensure your component is inside <WSEProvider>.
zustand is not installed or version mismatch
Missing or incompatible peer dependency zustand.
fix
Install zustand@>=4: npm install zustand.
Handshake failed: encryption required
Server requires encryption but client not configured properly.
fix
Set encryption: 'required' in client options or use a server that supports unencrypted connections.
Upgrade
Version history
2.3.2latest on npm
Audit
Dependencies
reactrequiredpeer dependency for hooks and component integration
zustandrequiredpeer dependency for WebSocket connection state management
Agent activity
34 hits · last 30 days
node
30
OpenAI (training)
1
Resources
wse-client — npm install wse-client · libregistry