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

@raucheacho/konet-js

v0.5.0

Published

JavaScript SDK for Konet realtime infrastructure

Readme

@raucheacho/konet-js

Type-safe JavaScript/TypeScript client for Konet, the self-hosted realtime engine (channels, presence, broadcast). Works in browsers and Node.js.

Install

npm install @raucheacho/konet-js

Usage

import { createClient } from '@raucheacho/konet-js'

const client = createClient('ws://localhost:4000/socket', {
  token: '<anon_key>',
})

const channel = client.channel('room:lobby')
await channel.subscribe()

channel.on('message', (payload) => console.log('Received:', payload))
channel.send('message', { text: 'Hello!' })

createClient connects immediately. Call client.disconnect() to close the socket.

Options

interface KonetClientOptions {
  token: string
  heartbeatIntervalMs?: number   // default: 30000
  reconnectDelayMs?: number      // default: 1000
  maxReconnectAttempts?: number  // default: 10
  heartbeatTimeoutMs?: number    // default: 10000
}

heartbeatTimeoutMs is how long the client waits for a heartbeat reply before declaring the socket dead. Keep it below the server's socket timeout (45s).

Reconnection

The client reconnects with exponential backoff and re-joins every channel you subscribed to, so a dropped connection is transparent to your code. A channel you left with unsubscribe() is never re-joined.

While disconnected, send() throws instead of writing into a socket the server no longer associates with your topic — a failed send is always visible.

After a re-join the server replays presence_state, so getPresence() is accurate again without any action on your part.

Send errors

Konet acknowledges a broadcast only when it refuses it (rate limiting, an unsupported payload). There is no ack on success, so send() stays fire-and-forget rather than returning a promise that could never settle.

Refusals surface two ways — per call, and per channel:

channel.send('audio', chunk, (err) => {
  console.warn('dropped:', err.reason)   // e.g. "rate_limited"
})

channel.on('send_error', (err) => metrics.increment(err.reason))
interface KonetSendError {
  topic: string
  event: string      // the application event you passed to send()
  payload: unknown
  reason: string     // server-supplied, e.g. "rate_limited"
}

This matters most on high-frequency streams (audio, telemetry), where the server's per-socket rate limit is reached silently otherwise. Raise it with KONET_RATE_LIMIT on the server if you see rate_limited under normal load.

Suspended environments

setInterval is a scheduler, not a clock: browsers throttle timers in inactive tabs and mobile runtimes freeze them outright. A suspended client can wake up with a socket that still reports OPEN long after the server timed it out.

Call checkConnection() whenever your host may have suspended the client. It probes the connection and reconnects if the probe goes unanswered — and revives a client that exhausted maxReconnectAttempts while suspended.

document.addEventListener('visibilitychange', () => {
  if (!document.hidden) client.checkConnection()
})

In React Native, use @raucheacho/konet-rn, which wires this to AppState for you.

Presence

channel.on('presence', (users) => console.log('Online:', users.length))

// or read the current snapshot
const users = channel.getPresence().list()

License

MIT