Registry / collaboration / js-bao-wss-client

js-bao-wss-client

JSON →
library2.0.1jsnpmunverified

A TypeScript/JavaScript client library (v2.0.1) for the js-bao-wss Yjs WebSocket service, providing document management, real-time collaborative editing, authentication (OAuth, magic link, OTP, passkey), permissions, invitations, blob storage, LLM chat, workflows, analytics, and offline support with automatic reconnection and storage fallback (IndexedDB in browsers, SQLite or in-memory in Node.js). Built for multi-tenant collaboration with Yjs CRDT and integrates with lib0, yjs, js-bao, better-sqlite3, y-sqlite3, and React. Released under MIT license.

npm install js-bao-wss-client
INSTALL
IMPORT
SIG · JS-BAO-WSS-CLIENT
J
js-bao-wss-client
collaborationjavascriptv2.0.1
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.

initializeClient
import { initializeClient } from 'js-bao-wss-client'
import initializeClient from 'js-bao-wss-client'
Default export is not available; must use named import. The function is async and returns a client instance.
JsBaoClient
import { JsBaoClient } from 'js-bao-wss-client'
const JsBaoClient = require('js-bao-wss-client').JsBaoClient
CommonJS require is deprecated since v2.0.0; ESM is the primary module system.
ClientOptions
import type { ClientOptions } from 'js-bao-wss-client'
import { ClientOptions } from 'js-bao-wss-client'
ClientOptions is a TypeScript type; use import type for isolated type imports.

Initialize the client with OAuth, create a document, and open it for real-time collaboration using Yjs.

import { initializeClient } from 'js-bao-wss-client'; import * as Y from 'yjs'; async function main() { const apiKey = process.env.JSBAO_API_KEY ?? 'your-api-key'; const client = await initializeClient({ appId: 'your-app-id', apiKey, auth: { type: 'oauth', tokenUrl: 'https://example.com/oauth/token', clientId: 'your-client-id', }, storageConfig: { type: 'memory' }, // optional }); // Create a document const docId = await client.documents.create({ name: 'My Doc' }); console.log('Created doc:', docId); // Open document for real-time collaboration const ydoc = new Y.Doc(); const provider = await client.open(ydoc, docId); ydoc.getArray('content').insert(0, ['Hello, world!']); // Clean up provider.disconnect(); ydoc.destroy(); } main().catch(console.error);
Debug
Known issues
breakinginitializeClient is now async and returns a promise; previous sync signature removed in v2.0.0
fix
Use await initializeClient(...) and handle the promise.
affects: >=2.0.0
deprecatedCommonJS require pattern is deprecated; ESM imports are required
fix
Use import statements instead of require().
affects: >=2.0.0
gotchaStorage auto-detection in Node.js will silently fall back to in-memory if better-sqlite3 is not installed, losing persistence
fix
Install better-sqlite3 as a dependency and ensure it is available at runtime, or explicitly set storageConfig to 'memory' if volatility is acceptable.
affects: >=1.0.0
gotchaOffline grants and auth tokens are stored in the storage provider; in-memory storage will lose them on restart
fix
Use a persistent storage config (better-sqlite3 or IndexedDB) to retain auth state across restarts.
affects: >=1.0.0
gotchaThe 'includeRoot' option for listing documents is opt-in by default; root documents are hidden unless explicitly requested
fix
Pass { includeRoot: true } to list documents method to include root documents.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'better-sqlite3'
better-sqlite3 is not installed but the client is running in Node.js and attempting to use SQLite storage
fix
Install better-sqlite3: npm install better-sqlite3, or force in-memory storage: storageConfig: { type: 'memory' }
TypeError: (0 , js_bao_wss_client.initializeClient) is not a function
Using default import instead of named import for initializeClient
fix
Change import to: import { initializeClient } from 'js-bao-wss-client'
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'create')
The client is not fully initialized when calling methods due to missing await on initializeClient
fix
Ensure await is used: const client = await initializeClient({...});
Error: Could not resolve the requested dependency 'lib0'
Missing peer dependency lib0 is not installed
fix
Install lib0: npm install lib0
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
yjsrequiredCore CRDT library for collaborative document sync
lib0requiredUtility library required by yjs
js-baorequiredBackend service dependency for API interactions
better-sqlite3optionalRequired for persistent storage in Node.js environments
y-sqlite3optionalSQLite binding for Yjs document persistence
reactoptionalOptional React integration (peer dependency)
Agent activity
37 hits · last 30 days
node
30
OpenAI (training)
1
Resources
js-bao-wss-client — npm install js-bao-wss-client · libregistry