An extensible, TypeScript-based WebSocket server for the Yjs collaborative editing framework, compatible with y-websocket. Version 0.2.3 (latest) is ESM-only and requires Node >=14.16. Unlike y-websocket's built-in server, yjs-server can be imported as a module, supports custom authentication with async authorization that buffers messages until resolved, and includes security fixes (e.g., against infinite loops on malformed messages). It ships TypeScript definitions. Release cadence is low; maintenance is active.
npm install yjs-serverNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a basic Yjs WebSocket server that handles collaborative editing using Y.Doc instances.
Switch to ESM imports (import ... from 'yjs-server') and ensure package.json contains "type": "module" or use .mjs extension.
Call yjss.handleConnection(socket, request) synchronously inside the 'connection' event handler.
Migrate from y-websocket's server to yjs-server using createYjsServer and handleConnection. See README.
Ensure the promise resolves with true for authorized connections. Any other value or rejection will close the connection.
Implement a timeout for the authorization promise to avoid resource exhaustion.
Change to `import { createYjsServer } from 'yjs-server'` and ensure package.json has "type": "module".Use `import { createYjsServer } from 'yjs-server'` and call createYjsServer to get the object with handleConnection.Check authorization logic and ensure the whenAuthorized promise resolves with true for valid connections.