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

relayly

v0.3.0

Published

Client library for the Relayly WebSocket relay server — simple, secure device-to-device messaging for local-first apps

Readme

relayly

TypeScript/JavaScript SDK for Relayly — a self-hosted, end-to-end encrypted WebSocket relay for local-first apps.

Works in Node.js, browsers, and React Native. Optional React hooks included.

Install

npm install relayly

Quick start

import { RelaylyClient, generateKey, encodeBase64, decodeBase64 } from 'relayly';

// Generate once and persist across sessions
const keyPair = generateKey();
localStorage.setItem('relayly_key', encodeBase64(keyPair.privateKey));

const client = new RelaylyClient('wss://relay.example.com', {
  deviceId: 'my-laptop',
  keyPair,
});

// Listen for messages
client.on('message', (msg) => {
  console.log(`[${msg.from}]`, msg.payload);
});

await client.connect();

Pairing

Devices pair using a short 6-digit code shared out-of-band (or via QR).

// Device A — request a code
const code = await client.requestPairCode();
console.log('Share this code:', code.shortCode);
// or display code.qrCodeUrl as a QR image

// Device B — accept the code
const peer = await client.acceptPair('483921');

After pairing, both sides fire the paired event automatically.

Sending messages

await client.send(peer.id, 'hello!');

// Raw bytes
await client.sendBytes(peer.id, new Uint8Array([1, 2, 3]));

Reconnection

The client reconnects automatically with exponential backoff:

client.on('disconnected', (reason) => console.warn('Lost connection:', reason));
client.on('reconnecting', (attempt) => console.log('Attempt', attempt));
client.on('connected', () => console.log('Back online'));

Disable it by setting reconnectDelayMs: 0 in options.

React hooks

import { useRelayly, usePairing } from 'relayly/react';

function Chat({ client, peerId }: { client: RelaylyClient; peerId: string }) {
  const { messages, send } = useRelayly(client, peerId);
  const { status, shortCode, qrCodeUrl, requestCode } = usePairing(client);

  if (status === 'waiting') return <QRCode value={qrCodeUrl!} />;

  return (
    <>
      {messages.map((m) => <p key={m.timestamp.toISOString()}>{m.payload}</p>)}
      <button onClick={() => send('hello')}>Send</button>
    </>
  );
}

React is a peer dependency — install it separately.

Options

| Option | Type | Default | Description | |---|---|---|---| | deviceId | string | — | Unique ID for this device. Required. | | keyPair | KeyPair | — | X25519 keypair. Use generateKey(). Required. | | pingIntervalMs | number | 30000 | Keepalive ping interval. | | reconnectDelayMs | number | 1000 | Initial reconnect delay. Set to 0 to disable. | | maxReconnectDelayMs | number | 60000 | Backoff ceiling. |

License

MIT