{"id":49805,"library":"y-socket.io","title":"y-socket.io","description":"Socket.IO connector for Yjs, inspired by y-websocket. Current stable version is 1.1.3. It provides a server and client implementation for synchronizing Yjs documents over Socket.IO, with features such as authentication, LevelDB persistence, custom callbacks, and cross-tab communication. It is a lightweight alternative to y-websocket for developers already using Socket.IO, offering easy integration and configuration.","status":"active","version":"1.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/ivan-topp/y-socketio","tags":["javascript","yjs","socket.io","y-socket.io","yjs-provider","yjs-connector","typescript"],"install":[{"cmd":"npm install y-socket.io","lang":"bash","label":"npm"},{"cmd":"yarn add y-socket.io","lang":"bash","label":"yarn"},{"cmd":"pnpm add y-socket.io","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for document synchronization","package":"yjs","optional":false}],"imports":[{"note":"Server-side class, exported from 'dist/server' subpath.","wrong":"import { YSocketIO } from 'y-socket.io'","symbol":"YSocketIO","correct":"import { YSocketIO } from 'y-socket.io/dist/server'"},{"note":"Client-side class, available as a top-level export.","wrong":"import { SocketIOProvider } from 'y-socket.io/dist/client'","symbol":"SocketIOProvider","correct":"import { SocketIOProvider } from 'y-socket.io'"},{"note":"Default export is available, but named imports are recommended. CJS require works but type definitions may not be resolved.","wrong":"const ySocketIO = require('y-socket.io/dist/server')","symbol":"default import","correct":"import ySocketIO from 'y-socket.io/dist/server'"}],"quickstart":{"code":"// server\nimport { Server } from 'socket.io';\nimport { YSocketIO } from 'y-socket.io/dist/server';\n\nconst io = new Server(1234);\nconst ysocketio = new YSocketIO(io);\nysocketio.initialize();\n\n// client (browser or node)\nimport * as Y from 'yjs';\nimport { SocketIOProvider } from 'y-socket.io';\n\nconst doc = new Y.Doc();\nconst provider = new SocketIOProvider('ws://localhost:1234', 'my-room', doc);\nprovider.on('status', ({ status }) => console.log(status));\n\ndoc.getMap('shared').observe(event => console.log('update', event));\n\n// cleanup on page unload\nwindow.addEventListener('beforeunload', () => provider.disconnect());","lang":"typescript","description":"Shows how to set up a basic y-socket.io server and client with Socket.IO and Yjs."},"warnings":[{"fix":"Avoid using namespaces that match the regular expression /^\\/yjs\\|.*$/ in your application.","message":"Socket.IO namespaces matching /^\\/yjs\\|.*$/ are reserved for y-socket.io. Do not use namespaces starting with '/yjs|' for other purposes.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Call ysocketio.initialize() after creating the YSocketIO instance.","message":"The server-side YSocketIO must be initialized with the initialize() method after constructing the instance.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Pass persistence options to YSocketIO constructor, e.g., new YSocketIO(io, { persistence: { levelPersistenceDir: './db' } }).","message":"Persistence is disabled by default; to enable LevelDB persistence, configure it via options.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.1.3':15 'alreadi':54 'altern':47 'authent':33 'callback':37 'client':21 'communic':42 'configur':61 'connector':3,71 'cross':40 'cross-tab':39 'current':11 'custom':36 'develop':53 'document':26 'easi':58 'featur':30 'implement':22 'inspir':6 'integr':59 'javascript':62 'leveldb':34 'lightweight':46 'offer':57 'persist':35 'provid':17,68 'server':19 'socket.io':2,28,56,64 'stabl':12 'synchron':24 'tab':41 'typescript':72 'use':55 'version':13 'websocket':10,51 'y':9,50 'y-socket.io':1,65 'y-websocket':8,49 'yjs':5,25,63,67,70 'yjs-connector':69 'yjs-provid':66","created_at":"2026-06-07T17:03:41.828667+00:00","updated_at":"2026-06-07T17:03:41.828667+00:00","problems":[{"fix":"Use import { YSocketIO } from 'y-socket.io/dist/server' (or require('y-socket.io/dist/server')).","cause":"The server import path requires the '/dist/server' subpath; importing from 'y-socket.io' only provides client exports.","error":"Cannot find module 'y-socket.io/dist/server'"},{"fix":"Ensure you pass a Yjs document: new SocketIOProvider(url, room, doc).","cause":"SocketIOProvider constructor's third argument (doc) is required and must be a Y.Doc instance.","error":"Error: You must provide a Yjs document"},{"fix":"Do not use namespaces starting with '/yjs|' for other purposes in your Socket.IO server.","cause":"Using a reserved namespace pattern; y-socket.io intercepts namespaces matching /^\\/yjs\\|.*$/.","error":"Error: The namespace \"/yjs|my-room\" is not allowed. Namespaces starting with \"/yjs|\" are reserved for y-socket.io."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/ivan-topp/y-socketio/blob/main/README.md","github":"https://github.com/ivan-topp/y-socketio","docs":null,"changelog":null,"pypi":null,"npm":"y-socket.io","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}