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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mgsmu-react

v1.0.5

Published

Minimal Global State Management Utility for React

Readme

mgsmu-react - Minimal Global State Management Utility

  • mgsmu-react is a lightweight global state management utility for React.
  • It provides a simple publish-subscribe (pub-sub) mechanism to manage global state without external libraries like Redux or Zustand.
  • Components can subscribe to specific keys and automatically re-render when those keys change.

install

npm install --save mgsmu-react

Import in any component

import { useStateStore } from 'mgsmu-react';
  • useStateStore() – React hook to access the global state and subscribe to changes.

Invoke state

const key = "data";
const [data, setData, removeData] = useStateStore(key);
  • Parameter names are flexible (data, setData and removeData are just examples).
  • keys can be used as you like. You can create as many keys as you like for different scenarios

Set data and key

const data = { specifics: "data", state: true, what: "next" };
setData(data)

// Functional Update 1.0.5
setData(prev => ({ ...prev, added: "new" }));
  • Key: any string can be used ("data", "users", "messages", etc.)
  • Data: any object or array can be stored under that key.
  • Allows management of multiple independent keys in your global state

Listen and catch changes

useEffect(() => {
    if (!data) return;
    console.log(data); //use Data
  },[data])
logs: {
    "specifics": "data",
    "state": true,
    "what": "next",
    "updatedAt": 1757423800721
}
  • useEffect triggers whenever the specified key (data in this example) changes.
  • Supports multiple keys — you can set up multiple useEffect hooks to listen to different keys individually.
  • Ensures components only re-render when the relevant slice of state updates.

Remove keys

removeData("data");
  • Deletes a key from the global state.
  • Make sure component is clean if rendered again
  • Note: Triggers re-render for components subscribed to that key.

Notes

  • Every state update includes an updatedAt timestamp.
  • The store works with any object structure, making it flexible for various use cases.
  • Lightweight and minimal — no context providers or extra boilerplate required.
  • Ideal for managing small to medium app state where a full state library would be overkill.

Changelog

All notable changes to this project will be documented in this file.


[1.0.5] - 2027-11-11

Fixed

  • Setter now supports functional update (like React’s setState)

[1.0.4] - 2027-10-22

Added

  • Added UseClickSetter
    • Only Clicking purpose

[1.0.3] - 2025-10-22

Fixed

  • Optimized listener notifications:
    • Only listeners subscribed to a changed or removed key are notified.
    • Previously, all listeners were notified on every state change.