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

@decentchat/transport-webrtc

v0.1.4

Published

WebRTC/PeerJS transport implementation for @decentchat/protocol

Readme

@decentchat/transport-webrtc

WebRTC transport for @decentchat/protocol. Connects peers over WebRTC data channels using PeerJS for signaling.

What it does

Implements the Transport interface from @decentchat/protocol so peers can send and receive messages over WebRTC. Handles signaling server connections, ICE/TURN negotiation, connection deduplication (glare resolution), heartbeat monitoring, and auto-reconnect with exponential backoff.

Supports multiple signaling servers simultaneously. Alice on signal.alice.com and Bob on signal.bob.com can talk if they share at least one server -- similar to how email MX records work. If both servers discover the same peer, only one connection is kept.

Install

npm install @decentchat/transport-webrtc

Depends on @decentchat/protocol and peerjs.

Quick start

import { PeerTransport } from '@decentchat/transport-webrtc';

const transport = new PeerTransport({
  signalingServers: ['https://0.peerjs.com/'],
});

transport.onConnect = (peerId) => console.log('connected:', peerId);
transport.onMessage = (peerId, data) => console.log('message from', peerId, data);

const myId = await transport.init();
await transport.connect('some-peer-id');
transport.send('some-peer-id', { hello: 'world' });

Embedded signaling server

Every node can run its own signaling server, removing the need for external infrastructure:

import { EmbeddedSignaling } from '@decentchat/transport-webrtc';

const server = new EmbeddedSignaling({ port: 9000 });
await server.start();
// Other peers can now connect via ws://your-ip:9000/peerjs

This runs in Node.js/Bun. Browser clients connect to it; they don't run it.

ICE/TURN configuration

Three ICE server constants are exported for convenience:

  • DEFAULT_ICE_SERVERS -- Google STUN servers
  • DEFAULT_TURN_SERVERS -- open relay TURN (dev only, rate-limited)
  • ICE_SERVERS_WITH_TURN -- both combined

For production, pass your own TURN credentials:

const transport = new PeerTransport({
  signalingServers: ['https://signal.example.com/peerjs'],
  turnServers: [
    { urls: 'turn:turn.example.com:443', username: 'user', credential: 'pass' },
  ],
});

On localhost, ICE servers are skipped entirely (host candidates work fine, and STUN timeouts break tests).

Config reference

PeerTransportConfig fields:

| Field | Default | Description | |-------|---------|-------------| | signalingServer | -- | Single server URL (legacy) | | signalingServers | [] | Multiple servers for federation | | iceServers | auto | Full override for ICE config | | useTurn | true | Include TURN servers (auto-false on localhost) | | turnServers | open relay | Custom TURN servers | | debug | 1 | PeerJS log level (0-3) | | maxRetries | 3 | Connection retries per server | | retryDelayMs | 2000 | Base retry delay (doubles each attempt) |

Build

npm run build    # compiles to dist/ via tsc

Both compiled JS (dist/) and raw TypeScript (src/) are included in the npm package. Bun users get direct .ts imports via the "bun" export condition.

Repository

This package lives in the decent-transport-webrtc/ directory of the DecentChat monorepo.

License

MIT