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

@fluxstack/live-client

v0.5.0

Published

Browser WebSocket client for @fluxstack/live — connection, state sync, rooms, and file upload (framework-agnostic)

Readme

@fluxstack/live-client

Framework-agnostic browser client for @fluxstack/live.

Works with any UI framework (React, Vue, Svelte, vanilla JS) or no framework at all. For React-specific bindings, see @fluxstack/live-react.

Installation

NPM/Bun

bun add @fluxstack/live-client

Browser (IIFE)

<script src="/live-client.js"></script>
<script>
  const counter = FluxstackLive.useLive('Counter', { count: 0 })
</script>

The IIFE bundle is served automatically by any transport adapter at /live-client.js.

Quick Start

Vanilla JS (useLive)

import { useLive, onConnectionChange } from '@fluxstack/live-client'

// Mount a component (uses singleton connection)
const counter = useLive('Counter', { count: 0 })

// Listen for state changes
counter.on(state => {
  document.getElementById('count').textContent = state.count
})

// Call server actions
document.getElementById('btn').onclick = () => counter.call('increment')

// Connection status
onConnectionChange(connected => {
  console.log(connected ? 'Online' : 'Offline')
})

Manual Connection

import { LiveConnection, LiveComponentHandle } from '@fluxstack/live-client'

const conn = new LiveConnection({
  url: 'ws://localhost:3000/api/live/ws',
  autoReconnect: true,
  reconnectInterval: 1000,
})
await conn.connect()

const counter = new LiveComponentHandle(conn, {
  componentName: 'Counter',
  defaultState: { count: 0 },
})

counter.on(state => console.log('Count:', state.count))
await counter.call('increment')

API

useLive(componentName, defaultState, options?)

High-level API using a shared connection singleton:

const handle = useLive('Counter', { count: 0 }, {
  url: 'ws://localhost:3000/api/live/ws',  // Auto-detected if omitted
  room: 'my-room',                          // Optional room
  singleton: true,                           // Singleton mount
})

handle.on(state => { ... })    // State change listener
handle.call('action', payload) // Call server action
handle.destroy()               // Unmount component

onConnectionChange(callback)

Subscribe to connection status changes:

const unsubscribe = onConnectionChange(connected => { ... })

getConnection()

Access the shared connection singleton:

const conn = getConnection()

LiveConnection

WebSocket connection manager with auto-reconnect, state rehydration, and message routing:

const conn = new LiveConnection({
  url: 'ws://localhost:3000/api/live/ws',
  autoReconnect: true,
  reconnectInterval: 1000,
  auth: {
    token: 'my-jwt-token',
    provider: 'jwt',
  },
})

LiveComponentHandle

Handle to a remote component. Manages mounting, state updates, and action calls:

const handle = new LiveComponentHandle(conn, {
  componentName: 'Counter',
  defaultState: { count: 0 },
  room: 'optional-room',
})

handle.on(state => { ... })     // State listener
handle.call('action', payload)  // Call action
handle.$state                   // Current state
handle.$connected               // Connection status
handle.destroy()                // Unmount

RoomManager

Client-side room event management:

const rooms = new RoomManager(conn)
const room = rooms.join('chat-room')
room.on('message:new', data => { ... })
room.emit('typing', { user: 'Alice' })
room.leave()

ChunkedUploader

Stream file uploads over WebSocket:

const uploader = new ChunkedUploader(conn, {
  chunkSize: 64 * 1024,
  onProgress: (progress) => { ... },
})
await uploader.upload(file)

State Persistence

import { persistState, getPersistedState, clearPersistedState } from '@fluxstack/live-client'

persistState('Counter', componentId, state, signature)
const saved = getPersistedState('Counter', componentId)
clearPersistedState('Counter', componentId)

Browser IIFE Build

The package includes a pre-built browser bundle at dist/live-client.browser.global.js that exposes a FluxstackLive global with all exports. Transport adapters serve this automatically at /live-client.js.

License

MIT