Skip to content
WebRTC Connector for Yjs
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.
bin bump lib0 to 0.2 (esm modules) Jan 13, 2020
demo bump lib0 to 0.2 (esm modules) Jan 13, 2020
src implement maxConns that prevents too many connections Jan 27, 2020
.gitignore rewrite for v13 Dec 5, 2019
LICENSE updated package.json, major version upgrade, added peerDependencies Feb 23, 2016
now.json rewrite for v13 Dec 5, 2019
package-lock.json bump lib0 Feb 19, 2020
package.json bump lib0 Feb 19, 2020
rollup.config.js fix localimports path ending Jan 14, 2020

WebRTC Connector for Yjs

It propagates document updates directly to all users via WebRTC.

  • Fast message propagation
  • Encryption and authorization over untrusted signaling server
  • No setup required, public signaling servers are available
  • Very little server load
  • Not suited for a large amount of collaborators on a single document (each peer is connected to each other)


npm i y-webrtc
Client code
import * as Y from 'yjs'
import { WebrtcProvider } from '../src/y-webrtc.js'

const ydoc = new Y.Doc()
// clients connected to the same room-name share document updates
const provider = new WebrtcProvider('your-room-name', ydoc, { password: 'optional-room-password' })
const yarray = ydoc.get('array', Y.Array)

The peers find each other by connecting to a signaling server. This package implements a small signaling server in ./bin/server.js.

# start signaling server
PORT=4444 node ./bin/server.js

Peers using the same signaling server will find each other. You can specify several custom signaling servers like so:

const provider = new WebrtcProvider('your-room-name', ydoc, { signaling: ['wss://', 'ws://localhost:4444'] })


y-webrtc uses the lib0/logging.js logging library. By default this library disables logging. You can enable it by specifying the log environment / localStorage variable:

// enable logging for all modules
localStorage.log = 'true'
// enable logging only for y-webrtc
localStorage.log = 'y-webrtc'
// by specifying a regex variables
localStorage.log = '^y.*'
# enable y-webrtc logging in nodejs
LOG='y-webrtc' node index.js


Yjs is licensed under the MIT License.

You can’t perform that action at this time.