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

@socketly/client

v0.1.1

Published

Browser client for Socketly — realtime channels, presence, and reconnect handling with no setup.

Readme

@socketly/client

Realtime channels in the browser. Connect with a public key, subscribe, and receive events — no server to run, no adapter to configure.

npm install @socketly/client

Connect

import { Socketly } from '@socketly/client';

const socketly = new Socketly({
  key: process.env.NEXT_PUBLIC_SOCKETLY_KEY!, // pk_app_…
});

const channel = socketly.subscribe('public-status');

channel.bind('deployed', ({ data }) => {
  console.log(data.version, 'is live');
});

The public key is safe in a browser — that is what it is for. It can subscribe to public channels and nothing else. Anything private needs a signature from your backend, which is the next section.

Private and presence channels

A channel name's prefix decides its rules:

| Prefix | Who can subscribe | |---|---| | public- | anyone with the public key | | private- | only with a signature from your server | | presence- | same, plus a signed identity that appears in the roster |

For the last two, point the client at an endpoint on your own backend:

const socketly = new Socketly({
  key: process.env.NEXT_PUBLIC_SOCKETLY_KEY!,
  authEndpoint: '/api/socketly/auth',
});

The client posts { socket_id, channel_name } there whenever it needs authorization. Your endpoint decides whether that user may subscribe — you already know who they are — and signs the answer with @socketly/server. Your secret key never leaves your server, and we never need to know your user model.

The signature is bound to the socket id, so it cannot be replayed on a different connection.

Reconnects

Every subscription is replayed on reconnect, and each private channel is re-authorized against the new socket id. You do not resubscribe by hand, and a signature from the old connection is never reused.

socketly.onStateChange((state) => {
  // 'initialized' | 'connecting' | 'connected' | 'reconnecting' | 'disconnected' | 'failed'
});

Presence

const channel = socketly.subscribe('presence-room-42');

channel.bind('socketly:subscription_succeeded', () => {
  console.log(channel.members.toArray()); // [{ userId, userInfo }]
});

channel.bind('socketly:member_added', (member) => { /* … */ });
channel.bind('socketly:member_removed', (member) => { /* … */ });

The identity in the roster comes from inside the signed payload, so a client cannot claim to be someone else.

Client events

Browser-to-browser events, for things like typing indicators that are not worth a round trip through your backend. They must be enabled on the app, are only allowed on private-/presence- channels, and their names must start with client-.

socketly.trigger('presence-room-42', 'client-typing', { userId });

Options

| Option | Default | | |---|---|---| | key | — | required, pk_app_… | | url | https://api.socketly.co | point at a local gateway in development | | authEndpoint | — | required for private-/presence- | | authHeaders | — | object, or a function called per request | | autoConnect | true | set false to call connect() yourself | | reconnection | true | | | debug | false | logs protocol activity to the console |

React

@socketly/react wraps this in useChannel and usePresence.

Full documentation: docs.socketly.co

MIT