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

storio

v1.0.6

Published

A simple React store provider

Readme

Storio

A lightweight, efficient state management solution for React with zero dependencies beyond React itself. Storio gives you the simplicity of Zustand with the predictability of useSyncExternalStore, without providers, contexts, or boilerplate.

Why choose Storio over Zustand or Redux?

  • ⚖️ Zero overhead: No providers, no context, no middleware layer — just a tiny hook-based store
  • 🧩 Drop‑in simplicity: API mirrors the mental model of Zustand’s create, but even smaller
  • ⚡ Selective re-renders: Components only update when the selected slice changes
  • 🔍 Deep equality guard: Built-in deep comparison prevents unnecessary updates out of the box
  • 🧠 Predictable by design: Powered by useSyncExternalStore for React‑official subscription semantics and SSR safety
  • 📦 Zero dependencies: Only react as a peer dependency

Features

  • 🪶 Lightweight: Minimal implementation using React's built-in hooks
  • Efficient: Components re-render only when their selected state changes
  • 🎯 Targeted Updates: Fine-grained control over component re-renders
  • 🔄 Simple API: Intuitive interface for state management
  • 📦 Zero Dependencies: Only requires React as a peer dependency
  • 🎨 Flexible: Support for both simple and complex state patterns

Installation

npm install storio
# or
pnpm add storio
# or
yarn add storio

Basic Usage

Here's a simple counter example that demonstrates the basic usage of Storio:

import { create } from 'storio';

// Create a store with initial state and actions
const useCounter = create((set) => ({
  count: 0,
  increment: () => set((state) => ({ count: state.count + 1 })),
  decrement: () => set((state) => ({ count: state.count - 1 }))
}));

// Use the store in your component
function Counter() {
  const {count} = useCounter();
  const { increment, decrement } = useCounter();

  return (
    <div>
      <button onClick={decrement}>-</button>
      <span>{count}</span>
      <button onClick={increment}>+</button>
    </div>
  );
}

Advanced Usage

Storio supports more complex state patterns with custom selectors and computed values. Here's an example of a responsive dimensions store:

import { create } from 'storio';

export const dimensionsStore = create((set) => ({
    vw: 0,
    setVw: (width) => set({ vw: width }),
    
    // Computed values using store state
    isMobile: () => {
        const { vw } = dimensionsStore.getState();
        return vw <= 480;
    },
    isTablet: () => {
        const { vw } = dimensionsStore.getState();
        return vw > 480 && vw <= 1024;
    },
    isDesktop: () => {
        const { vw } = dimensionsStore.getState();
        return vw >= 1024;
    }
}));

// Usage in components
function ResponsiveComponent() {
  const { isMobile } = dimensionsStore();
  
  return (
    <div>
      { isMobile() ? 'Mobile View' : 'Desktop View' }
    </div>
  );
}

Pattern: Expose computed helpers on the store and destructure them in components for clarity and reuse. Alternatively, you can select primitives with a selector if you prefer returning a boolean directly.

Storio vs Zustand vs Redux (quick comparison)

| Criteria | Storio | Zustand | Redux Toolkit | |---|---|---|---| | Provider required | No | No | Yes (<Provider>) | | Dependencies | React peer only | zustand | @reduxjs/toolkit, react-redux | | API surface | Tiny | Small | Larger | | Boilerplate | None | Low | Medium | | Selective re-render | Yes (selector) | Yes (selector) | Yes (useSelector) | | Equality logic | Deep equality built-in | Shallow/ref equality by default | Custom via useSelector | | DevTools | Manual integration | Via middleware | Built-in DevTools | | Middleware | Not needed for basics | Optional addons | First-class | | SSR-safe | Yes (useSyncExternalStore) | Yes | Yes | | Learning curve | Very low | Low | Medium |

If you want the smallest, most readable solution without sacrificing control, Storio is a great fit. If you need time‑travel debugging or a middleware ecosystem out‑of‑the‑box, Redux Toolkit remains excellent.

Performance

Storio is built with performance in mind:

  1. Selective Re-rendering: Components only re-render when their selected state changes, not on every state update
  2. Deep Equality Checks: Prevents unnecessary re-renders by performing deep equality comparisons on state changes
  3. Fine-grained Updates: Use selectors to subscribe to specific parts of the state

API Reference

create(storeCreator)

Creates a new store with the given initial state and actions.

  • storeCreator: function that receives (set, get) and returns the initial state and actions
  • Returns a hook that can be used to access the store state and actions

Store Hook

The created hook provides several features:

  • State Selection: const value = useStore((state) => state.value)
  • Action Access: const { setValue } = useStore()
  • Direct State Access: useStore.getState()
  • State Updates: useStore.setState(nextOrUpdater)
  • Subscription: useStore.subscribe(listener)

SSR: Storio uses useSyncExternalStore under the hood, providing correct server and client semantics without extra configuration.

Migration

From Zustand

Most stores migrate by changing the import. If your store only uses set, it’s a pure drop‑in.

// Before
import { create } from 'zustand';

const useCounter = create((set) => ({
  count: 0,
  increment: () => set((s) => ({ count: s.count + 1 })),
}));

// After
import { create } from 'storio';

const useCounter = create((set) => ({
  count: 0,
  increment: () => set((s) => ({ count: s.count + 1 })),
}));

If you used Zustand’s get, Storio exposes it as the second argument to create((set, get) => ...) and also via useStore.getState().

From Redux / RTK

Replace slices and reducers with a small store and explicit actions. No provider needed.

// Instead of slice + reducers
import { create } from 'storio';

export const useTodos = create((set, get) => ({
  items: [],
  add: (title) => set((s) => ({ items: [...s.items, { id: Date.now(), title }] })),
  remove: (id) => set((s) => ({ items: s.items.filter((t) => t.id !== id) })),
}));

function TodoList() {
  const items = useTodos((s) => s.items);
  const { add, remove } = useTodos();
  // ...
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT