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

magos

v1.0.5

Published

Strictly-typed state management for React and Vanilla JS.

Readme

Magos

Magos Logo

A lightweight, strictly-typed state management library for React and Vanilla JS, built with a focus on data integrity and developer experience.

Unlike other libraries that allow "empty" or "undefined" states to creep into your logic, Magos enforces strict rules at the core level to prevent common frontend bugs before they happen.

✨ Key Features

  • 🛡️ Zero-Empty-Object Policy: Prevents initializing or updating state with an empty object {}.

  • 🚫 Serializable Integrity: Blocks functions within the state to ensure data remains clean and predictable.

  • ⚛️ React 18 Ready: Uses useSyncExternalStore for tear-free, synchronized rendering in Concurrent Mode.

  • 🍦 Vanilla Support: Effortless DOM synchronization via unbox without any framework overhead.

  • 🕵️ Conflict Detection: Built-in ID tracking (magos_id) prevents accidental duplicate box registration in your store.

  • 🧊 Type Safe: Deep TypeScript integration with zero-config type inference.


📥 Installation

npm install magos-react
# or
yarn add magos-react

🚀 Quick Start

  1. Create a Box

Define your state and actions. Magos will warn you if you try to pass invalid state patterns.

import { createBox } from 'magos-react';

// Full support for primitives and non-empty objects
export const counterBox = createBox(0, (set) => ({
  inc: () => set(prev => prev + 1),
  reset: () => set(0)
}));
  1. Connect to React

No Providers needed. Just hook it up and go.

import { useAppStore } from 'magos-react/react';
import { counterBox } from './store';

function Counter() {
  const [count, actions] = useAppStore(counterBox);

  return <button onClick={actions.inc}>{count}</button>;
}
  1. Use in Vanilla JS

Sync your state directly to the UI with automatic cleanup support.

import { unbox } from 'magos-react/vanilla';
import { counterBox } from './store';

const el = document.querySelector('#counter');
const [state, actions, unsubscribe] = unbox(counterBox, el);

⚖️ The Magos Philosophy

Magos is built on the belief that State should be meaningful. 1. No undefined updates: State must always have a value (null, 0, and false are fine). 2. No empty objects: If you have an object, it should have data. {} is often a sign of uninitialized or missing data. 3. Reference Stability: Actions are generated once and remain stable, preventing unnecessary re-renders.


📖 API Reference

createBox(initialState, actionFactory) Creates a reactive state container.

Validation: Warns/Throws on undefined, {}, or functions within the state object.

createStore(boxes) Combines multiple boxes into a central registry.

Validation: Ensures every box is unique via internal magos_id.

useAppStore(box) A React hook for synchronized state access.

unbox(box, targets, selector?) Synchronizes state with one or more HTML elements.


📜 License MIT

👤 Author Nguyen Huy Long