Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

y-protocols

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

y-protocols

Yjs encoding protocols

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
371K
increased by9.76%
Maintainers
1
Weekly downloads
 
Created

What is y-protocols?

The y-protocols npm package provides a set of protocols for building collaborative applications using Yjs, a high-performance CRDT (Conflict-free Replicated Data Type) framework. It includes protocols for awareness, WebRTC, and WebSocket communication, enabling real-time collaboration features such as shared editing and presence awareness.

What are y-protocols's main functionalities?

Awareness Protocol

The Awareness protocol allows you to manage and track the presence and state of users in a collaborative session. This can be used to show who is online and their current activity or status.

const { Awareness } = require('y-protocols/awareness');
const awareness = new Awareness(doc);

// Set user state
awareness.setLocalStateField('user', { name: 'Alice' });

// Listen for changes in awareness
awareness.on('change', changes => {
  console.log('Awareness changed:', changes);
});

WebRTC Protocol

The WebRTC protocol enables peer-to-peer communication for real-time collaboration. It allows users to connect directly to each other without the need for a central server.

const { WebrtcProvider } = require('y-protocols/webrtc');
const provider = new WebrtcProvider('my-room-name', doc);

// Listen for connection events
provider.on('synced', () => {
  console.log('Synced with WebRTC peers');
});

WebSocket Protocol

The WebSocket protocol facilitates real-time communication over WebSocket connections. This is useful for scenarios where a central server is required to manage connections and data synchronization.

const { WebsocketProvider } = require('y-protocols/websocket');
const provider = new WebsocketProvider('wss://my-websocket-server', 'my-room-name', doc);

// Listen for connection events
provider.on('status', event => {
  console.log('WebSocket connection status:', event.status);
});

Other packages similar to y-protocols

Keywords

FAQs

Package last updated on 18 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc