npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

collabdoc-sdk

v1.0.1

Published

Real-time collaborative document editing SDK powered by Yjs CRDTs and Socket.IO. Add Google Docs-style collaboration to any React app in minutes.

Readme

collabdoc-sdk

Real-time collaborative document editing SDK powered by Yjs CRDTs and Socket.IO.
Add Google Docs-style collaboration to any React app in minutes.

npm version License: MIT

Features

  • Conflict-Free Merging — Yjs CRDTs guarantee zero data loss, even with simultaneous edits
  • Real-Time Sync — Sub-50ms latency over Socket.IO WebSockets
  • Presence & Cursors — See who's online and where they're typing
  • Offline Support — Keep editing offline; changes merge seamlessly on reconnect
  • JWT Authentication — Secure room-based access with any auth provider
  • Zero Config — All dependencies bundled; just npm install and go

Quick Start

1. Install

npm install collabdoc-sdk

2. Use the React Hook

import { useCollabDoc } from 'collabdoc-sdk/react';

function CollaborativeEditor() {
  const { doc, isConnected, isSynced, presence, error } = useCollabDoc({
    roomId: 'my-document-123',
    serverUrl: 'https://your-collab-server.com',
    user: { name: 'Alice', color: '#0070f3' },
    token: 'your-jwt-token', // optional
  });

  // Get the collaborative text
  const yText = doc?.getText('content');
  const text = yText?.toString() || '';

  // Write to the document
  const handleChange = (e) => {
    doc?.getYDoc().transact(() => {
      yText?.delete(0, yText.length);
      yText?.insert(0, e.target.value);
    });
  };

  return (
    <div>
      <p>{isConnected ? 'Connected' : 'Connecting...'}</p>
      <p>{presence.size} users online</p>
      <textarea value={text} onChange={handleChange} />
    </div>
  );
}

3. Use Without React

import { CollabDoc } from 'collabdoc-sdk';

const doc = new CollabDoc({
  roomId: 'my-document-123',
  serverUrl: 'https://your-collab-server.com',
  user: { name: 'Bob', color: '#34d399' },
});

doc.on('connect', () => console.log('Connected!'));
doc.on('synced', () => console.log('Document synced!'));
doc.on('change', ({ origin }) => console.log(`Change from ${origin}`));

doc.connect();

// Key-Value API
doc.set(['settings', 'theme'], 'dark');
console.log(doc.get(['settings', 'theme'])); // 'dark'

// Rich Text API
const yText = doc.getText('content');
yText.insert(0, 'Hello, World!');

API Reference

useCollabDoc(options) — React Hook

| Option | Type | Required | Description | |--------|------|----------|-------------| | roomId | string | ✅ | Unique document/room identifier | | serverUrl | string | ✅ | CollabDoc WebSocket server URL | | user | { name, color } | ❌ | User info for presence | | token | string | ❌ | JWT token for authentication |

Returns:

| Field | Type | Description | |-------|------|-------------| | doc | CollabDoc \| null | The CollabDoc instance | | isConnected | boolean | WebSocket connection status | | isSynced | boolean | Initial sync complete | | presence | Map<number, AwarenessUser> | Online users and cursors | | error | Error \| null | Connection/auth errors |

CollabDoc — Core Class

Key-Value API

doc.set(['path', 'to', 'key'], value)   // Set nested value
doc.get(['path', 'to', 'key'])          // Read value
doc.delete(['path', 'to', 'key'])       // Delete key
doc.getDocumentState()                  // Full document as JSON

Rich Text API

const yText = doc.getText('fieldName')  // Get Y.Text instance
yText.insert(0, 'Hello')               // Insert text
yText.delete(0, 5)                     // Delete text
yText.toString()                       // Read full text

Presence API

doc.setCursor({ path: 'content', offset: 42 })  // Broadcast cursor
doc.getPresence()                                 // Get all users
doc.getAwareness()                                // Raw Awareness instance

Events

doc.on('connect', () => {})             // WebSocket connected
doc.on('disconnect', (reason) => {})    // WebSocket disconnected
doc.on('synced', () => {})              // Initial sync complete
doc.on('change', ({ origin }) => {})    // Document changed
doc.on('awareness', (states) => {})     // Presence updated
doc.on('error', (err) => {})            // Error occurred

Server Setup

The SDK requires a CollabDoc-compatible WebSocket server. See the server documentation for setup instructions.

# Clone and run the server
git clone https://github.com/gautamkumar34/Real-time-collaboration-SDK.git
cd Real-time-collaboration-SDK/server
npm install
npm run dev

License

MIT © Gautam Kumar