{"id":16505,"library":"protoo-client","title":"protoo-client","description":"protoo-client is the client-side JavaScript library for the protoo signaling framework, designed for building multi-party Real-Time Communication (RTC) applications. It supports both browser and Node.js environments, requiring a compatible WebSocket implementation (native `WebSocket` in browsers, or a library like `ws` in Node.js). The current stable version is 4.0.8, and the project appears to follow semantic versioning with notable breaking changes between major releases, indicating active development. It differentiates itself by offering a minimalist and extensible approach to signaling, focusing specifically on WebRTC use cases.","status":"active","version":"4.0.8","language":"javascript","source_language":"en","source_url":"https://github.com/ibc/protoo","tags":["javascript","nodejs","browser","websocket"],"install":[{"cmd":"npm install protoo-client","lang":"bash","label":"npm"},{"cmd":"yarn add protoo-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add protoo-client","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for Node.js environments to provide a WebSocket implementation, as protoo-client does not bundle one.","package":"ws","optional":true}],"imports":[{"note":"The core `Peer` class is a named export. Ensure you provide a WebSocket instance (native browser WebSocket or `ws` for Node.js) when instantiating.","wrong":"import Peer from 'protoo-client';","symbol":"Peer","correct":"import { Peer } from 'protoo-client';"},{"note":"While the latter might work, destructuring directly is the idiomatic CommonJS way to access named exports. ESM is preferred for new projects.","wrong":"const protooClient = require('protoo-client');\nconst Peer = protooClient.Peer;","symbol":"protoo-client in CJS","correct":"const { Peer } = require('protoo-client');"}],"quickstart":{"code":"import { Peer } from 'protoo-client';\nimport { WebSocket } from 'ws'; // Only for Node.js. In browsers, use native WebSocket.\n\nconst WEBSOCKET_URL = process.env.PROTOO_SERVER_URL || 'wss://your.protoo.server:4443';\n\nasync function connectProtoo() {\n  let ws;\n  if (typeof window === 'undefined') {\n    // Node.js environment\n    ws = new WebSocket(WEBSOCKET_URL);\n  } else {\n    // Browser environment\n    ws = new WebSocket(WEBSOCKET_URL);\n  }\n\n  const peer = new Peer(ws);\n\n  peer.on('open', () => {\n    console.log('Protoo Peer connected to server!');\n    // Example: Send an initial request\n    peer.request('hello', { message: 'Hello from client!' })\n      .then(response => console.log('Server response:', response))\n      .catch(error => console.error('Request failed:', error));\n  });\n\n  peer.on('close', () => {\n    console.log('Protoo Peer disconnected.');\n  });\n\n  peer.on('error', (error) => {\n    console.error('Protoo Peer error:', error.message);\n  });\n\n  peer.on('request', async (request, accept, reject) => {\n    console.log('Received request from server:', request.method, request.data);\n    try {\n      if (request.method === 'ping') {\n        accept({ pong: 'received' });\n      } else {\n        reject(new Error('Unknown request method'));\n      }\n    } catch (error) {\n      reject(error);\n    }\n  });\n\n  peer.on('notification', (notification) => {\n    console.log('Received notification from server:', notification.method, notification.data);\n  });\n}\n\nconnectProtoo();","lang":"typescript","description":"This quickstart demonstrates how to instantiate a protoo-client Peer, establish a WebSocket connection, and handle basic 'open', 'close', 'error', 'request', and 'notification' events. It distinguishes between Node.js and browser WebSocket usage."},"warnings":[{"fix":"Update all calls from `peer.send(method, data)` to `peer.request(method, data)`.","message":"The `peer.send()` method has been renamed to `peer.request()` in protoo-client v4. Attempting to use `send()` will result in a runtime error.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"For Node.js projects, install `ws` (`npm install ws`) and import it: `import { WebSocket } from 'ws';` then pass an instance to `new Peer(new WebSocket(url))`.","message":"When using `protoo-client` in Node.js, you must explicitly provide a WebSocket implementation, typically by installing and importing the `ws` package. Browsers provide a native `WebSocket` global.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'4.0.8':59 'activ':76 'appear':63 'applic':30 'approach':87 'break':70 'browser':34,46,98 'build':21 'case':95 'chang':71 'client':3,6,10 'client-sid':9 'communic':28 'compat':40 'current':55 'design':19 'develop':77 'differenti':79 'environ':37 'extens':86 'focus':90 'follow':65 'framework':18 'implement':42 'indic':75 'javascript':12,96 'librari':13,49 'like':50 'major':73 'minimalist':84 'multi':23 'multi-parti':22 'nativ':43 'node.js':36,53 'nodej':97 'notabl':69 'offer':82 'parti':24 'project':62 'protoo':2,5,16 'protoo-cli':1,4 'real':26 'real-tim':25 'releas':74 'requir':38 'rtc':29 'semant':66 'side':11 'signal':17,89 'specif':91 'stabl':56 'support':32 'time':27 'use':94 'version':57,67 'webrtc':93 'websocket':41,44,99 'ws':51","created_at":"2026-04-22T04:50:44.029190+00:00","updated_at":"2026-04-22T04:50:44.029190+00:00","problems":[{"fix":"Rename `peer.send()` to `peer.request()`. This was a breaking change in v4.","cause":"Attempting to use the deprecated `send()` method on a `Peer` instance from `protoo-client` version 4 or newer.","error":"peer.send is not a function"},{"fix":"Install the `ws` package (`npm install ws`) and import it. Then, pass an instance of `ws.WebSocket` to the `Peer` constructor, e.g., `new Peer(new WebSocket(url))`.","cause":"This error typically occurs when running `protoo-client` in a Node.js environment without providing a WebSocket implementation. The browser's native `WebSocket` is not available in Node.js.","error":"ReferenceError: WebSocket is not defined"},{"fix":"Ensure the WebSocket URL is correct, the `protoo-server` is running and accessible, and handle `peer.on('close')` and `peer.on('error')` events to detect and react to disconnections. Re-establish the `Peer` and WebSocket connection if necessary.","cause":"This error often indicates that the underlying WebSocket connection was closed unexpectedly or failed to establish, and an operation (like `peer.request()`) was attempted on a disconnected peer.","error":"Error: Peer closed"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://protoo.versatica.com","github":"https://github.com/ibc/protoo","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/protoo-client","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","http-networking","communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-21","install_tag":null}}