Skip to content
WebRTC Connector for Yjs
JavaScript HTML
Branch: master
Clone or download
Permalink
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 option to set awareness instance Dec 19, 2019
test bump lib0 to 0.2 (esm modules) Jan 13, 2020
.gitignore rewrite for v13 Dec 5, 2019
LICENSE updated package.json, major version upgrade, added peerDependencies Feb 23, 2016
README.md allow encryption and authorization over untrusted signaling server Dec 9, 2019
index.html allow encryption and authorization over untrusted signaling server Dec 9, 2019
now.json rewrite for v13 Dec 5, 2019
package-lock.json 10.1.0 Jan 13, 2020
package.json 10.1.0 Jan 13, 2020
rollup.config.js fix localimports path ending Jan 14, 2020
tsconfig.json

README.md

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)

Setup

Install
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)
Signaling

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://y-webrtc-ckynwnzncc.now.sh', 'ws://localhost:4444'] })

Logging

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

License

Yjs is licensed under the MIT License.

kevin.jahns@pm.me

You can’t perform that action at this time.