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

x-plus

v13.1.19

Published

A React State Management Library similar to mobx, redux.etc. it's the simplest, smallest and fastest state management library for react with dev tools support.

Readme

Easy and Simple State Management for React at 0.8kb

x-plus is a tiny and no nonsense state management library for react. It's alternative to redux, mobx, zustand, etc. It's easier and simpler to use as it's syntax is closer to useState hook.

Create a store

import { x } from "x-plus";

const store = x({ count: 0 }); // store is created

Access the store in react component

const [count, setCount] = useX(store); // similar to useState

<div onClick={() => setCount(count + 1)}>{count}</div>; // use in html

stackblitz Counter example

Stackblitz Todo Example

Counter React App Example

import { x, useX } from "x-plus";

// store
const countX = x({ count: 0 }));

function App() {
  const [count, setCount] = useX(countX);
  const incr = () => setCount({count: count + 1});
  return (
    <>
      <h1 onClick={incr}>{count}</h1> <br />
    </>
  );
}

export default App;

exploring the api

const countX = x({ address: { street: "123 Main St" } });

countX.getState(); // returns the current state of the store
countX.setState({ address: { street: "street updated" } }); // sets the new state for the store

countX.update((state) => (state.address.street = "new street")); // updates the state directly, you need to install immer-lite separately.

countX.reset(); // resets the state to intial state.
countX.getState(); // {address: {street: "123 Main St"}}

const street = countX.memo((state) => state.address.street); // returns the memoized value of the state

street.value; // "123 Main St"

const effect = countX.effect(
  () => {
    console.log("street is changed");
  },
  (state) => [state.address.street]
  // if you don't pass depsFn as second argument, it'll run whenever the Store is changed.
  // if you pass ()=>[], then it'll run only once.
); // it'll run the function passed as first argument whenever the deps change.
effect.unsub(); // you can unsubscribe from effect. itll stop logging "street is changed" whenever the street is changed.

subscribe: get notified when state is changed

const unsub = countX.subscribe((state) => {
  console.log(state);
});
unsub(); // you can unsubscribe from state changes.

storeFn (3 in 1)

store is a function when called with no arguments, it works like getState function and returns the state. when passed a new state as an argument, it'll work like a setState function. and when passed a function, it'll function similar to update function.

const store = x({ count: 0 });

//  similar to store.getState()
store(); // { count: 0 }

// similar to store.setState({ count: 1 })
store({ count: 1 }); // { count: 1 }

// similar to store.update((state) => state.count++)
store((state) => state.count++); // { count: 1 }

update with immer-lite

using immer-lite you can also update the state directly using update function. you can see in this example that we are not returning new state but updating the state directly. for this you need to install immer-lite as a dependency.

npm install immer-lite
countX.update((state) => {
  state.count++;
});

API

Store

  • getState(); returns the current state of the store
  • setState(newState); sets new state for the store
  • setState((state)=>state); sets the new state with function
  • update(state=>void); you can mutate state directly here.
  • reset(); resets the state to intial state.
  • subscribe(fn); it calls the call back function whenever the state is changed so uou can keep track of state changes.
  • effect(fn, depsFn?); it's like useEffect hook. if no depsFn is passed, it'll call the callback function whenever the state is changed. if depsFn is passed, it'll call the callback function only when the depsFn returns value is changed. if empty array is passed, it'll call the callback function only once.
  • memo(fn, depsFn?); it's similar to effect except it can return any value which gets memoized.
  • derive(fn, depsFn?); it's similar to memo.

useX

  • useX(store); returns an array of four items: current state of the store, setState function, update function, reset function.
  • useX(store, resetOnUnmount); returns the current state of the store and resets the state to intial state when the component is unmounted. very useful sometimes. Sometimes you want to reset the state when the user navigates to another page.

Contributing

Contributions are always welcome! If you find a bug or want to add a feature, please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

This project is created by Sean Freeman.

Acknowledgements

This project is inspired by simplicy of zustand.