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

wavesync

v1.0.4

Published

A lightweight state synchronization library for browser tabs.

Downloads

15

Readme

WaveSync

WaveSync is a lightweight, modular state management library designed for browser environments, with cross-tab synchronization capabilities. It allows developers to easily manage and synchronize application state across multiple browser tabs using BroadcastChannel.


Features

  • Global State Management: Add and manage modular states effortlessly.
  • Cross-Tab Synchronization: Automatically sync state updates across browser tabs.
  • Lightweight API: Intuitive and minimalistic API for quick integration.
  • Modular Design: Manage independent state modules to maintain cleaner code.

Installation

To install WaveSync, use npm or yarn:

npm install wavesync

Or using yarn:

yarn add wavesync

Usage

Importing WaveSync

import waveSync from 'wavesync';

Adding a Module

Add a module with an initial state:

waveSync.addModule('user', { name: 'Guest', age: 0 });

Updating Module State

Update the state of a module using the set method:

waveSync.modules['user'].set?.('name', 'John');
waveSync.modules['user'].set?.('age', 30);

Retrieving Module State

Get the current state of a specific module:

const userState = waveSync.getModule('user');
console.log(userState); // { name: 'John', age: 30 }

Retrieving Global State

Get the global state for all modules:

const globalState = waveSync.getState();
console.log(globalState);

Resetting State

Reset all modules and clear the global state:

waveSync.resetState();
console.log(waveSync.getState()); // {}

Advanced Features

Cross-Tab Synchronization

WaveSync uses BroadcastChannel to automatically synchronize state updates across multiple browser tabs. For example, if you update the state in one tab, the changes will reflect in all other tabs:

waveSync.modules['user'].set?.('name', 'Alice');
// All other open tabs will receive the updated state automatically.

Modular Design

Each module in WaveSync is independent, allowing you to manage state for specific features or components without polluting the global namespace.


Best Practices

  1. Use Descriptive Module Names: Choose clear and descriptive names for your modules (e.g., user, settings).
  2. Avoid Large States: Keep module states manageable and avoid storing large datasets directly.
  3. Combine with Persistence: Use localStorage or IndexedDB to persist state if needed.

Example Application

Here’s a complete example:

import waveSync from 'wavesync';

// Add modules
waveSync.addModule('user', { name: 'Guest', age: 0 });
waveSync.addModule('theme', { mode: 'light' });

// Update module states
waveSync.modules['user'].set?.('name', 'John Doe');
waveSync.modules['theme'].set?.('mode', 'dark');

// Retrieve state
console.log(waveSync.getModule('user')); // { name: 'John Doe', age: 0 }
console.log(waveSync.getState());

// Cross-tab synchronization works automatically!

License

WaveSync is open-source and available under the MIT License.


Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve WaveSync.