Package Exports
- y-webrtc
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (y-webrtc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
WebRTC Connector for Yjs
It propagates document updates directly to all users via WebRTC.
- Fast message propagation
- No setup required, a default signalling server is 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()
const provider = new WebrtcProvider('prosemirror', ydoc)
const yarray = ydoc.get('prosemirror', Y.XmlFragment)
Signalling
The peers find each other by connecting to a signalling server. This package implements a small signalling server in ./bin/server.js
.
# start signalling server
PORT=4444 node ./bin/server.js
Peers using the same signalling server will find each other. You can specify several custom signalling servers like so:
const provider = new WebrtcProvider('prosemirror', ydoc, { signalling: ['wss://y-webrtc-ckynwnzncc.now.sh', 'ws://localhost:4444'] })
License
Yjs is licensed under the MIT License.