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 🙏

© 2025 – Pkg Stats / Ryan Hefner

yjs-webtransport

v0.1.0

Published

WebTransport provider for Y.js — Real-time collaboration over QUIC with unreliable datagram support

Readme

yjs-webtransport

WebTransport provider for Y.js — Real-time collaboration over QUIC with unreliable datagram support.

npm version License: MIT

Features

  • 🚀 WebTransport/QUIC — Modern transport, faster than WebSocket
  • 19ms round-trip latency — Tested over real network conditions
  • 🎯 Unreliable datagrams — Perfect for cursor/presence updates
  • 🔄 Reliable streams — Document sync that never loses data
  • 🔌 Y.js compatible — Works as a provider for Y.js CRDTs
  • 📦 Zero head-of-line blocking — QUIC streams are independent

Why WebTransport over WebSocket?

| Feature | WebSocket | yjs-webtransport | |---------|-----------|-----------------| | Transport | TCP | QUIC | | Cursor latency | ~50ms+ under load | ~19ms consistent | | Head-of-line blocking | Yes | No | | Packet loss handling | Waits for retransmit | Datagrams skip it |

Installation

npm install yjs-webtransport yjs

Quick Start

import * as Y from 'yjs';
import { WebTransportProvider } from 'yjs-webtransport';

const doc = new Y.Doc();
const provider = new WebTransportProvider(
  'https://your-server.com',  // Your y-webtransport-go server
  'room-name',
  doc
);

// Listen for sync status
provider.on('synced', (synced) => {
  console.log('Document synced:', synced);
});

// Access awareness for cursors/presence
provider.awareness.setLocalStateField('user', {
  name: 'Alice',
  color: '#ff0000'
});

provider.awareness.setLocalStateField('cursor', {
  anchor: 0,
  head: 10
});

How It Works

┌─────────────────────────────────────────────────────────────┐
│                  yjs-webtransport Architecture               │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│   Document Changes ──► QUIC Stream (reliable) ──► Server    │
│                                                              │
│   Cursor Updates ──► QUIC Datagram (unreliable) ──► Server  │
│                                                              │
│   ┌─────────────────────────────────────────────────────┐   │
│   │  Datagrams: No retransmit = No waiting = 19ms        │   │
│   └─────────────────────────────────────────────────────┘   │
│                                                              │
└─────────────────────────────────────────────────────────────┘

API

WebTransportProvider

new WebTransportProvider(
  serverUrl: string,
  roomName: string,
  doc: Y.Doc,
  options?: WebTransportProviderOptions
)

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | awareness | Awareness | new Awareness(doc) | Custom awareness instance | | connect | boolean | true | Auto-connect on creation | | serverCertificateHashes | Array | - | For self-signed certs (dev) | | useUnreliableAwareness | boolean | true | Use datagrams for cursors | | awarenessUpdateInterval | number | 50 | Datagram broadcast interval (ms) | | maxReconnectAttempts | number | 10 | Max reconnection attempts |

Events

provider.on('synced', (synced: boolean) => {});
provider.on('status', ({ status }) => {});
provider.on('connection-error', (error: Error) => {});
provider.on('connection-close', (event) => {});

Properties

provider.connected  // boolean - connection status
provider.synced     // boolean - document sync status
provider.awareness  // Awareness - for cursors/presence
provider.doc        // Y.Doc - the Y.js document

Methods

provider.connect(): Promise<void>
provider.disconnect(): void
provider.destroy(): void

Server

You need a WebTransport server. Use our Go server:

y-webtransport-go (Official Server)

go install github.com/Kkartik14/y-webtransport-go@latest

See y-webtransport-go for setup.

TLS Certificates

WebTransport requires HTTPS.

Production: Use Let's Encrypt

sudo certbot certonly --standalone -d your-domain.com

Development: Self-signed + Chrome flag

# Enable chrome://flags/#webtransport-developer-mode

Browser Support

| Browser | Support | |---------|---------| | Chrome | ✅ 97+ | | Edge | ✅ 97+ | | Firefox | ✅ 114+ | | Safari | ⏳ Coming soon |

Benchmarks

Real network test (MacBook Air → Oracle Cloud India):

┌─────────────────────────────────────────────────┐
│ WebTransport Datagram Round-Trip                │
│   Average: 19.4ms                               │
│   P50: 17.7ms                                   │
│   P99: 46.1ms                                   │
│   Delivery: 499/500 (99.8%)                     │
└─────────────────────────────────────────────────┘

Related

License

MIT © Kartik Gupta