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

@odemian/react-store

v0.0.12

Published

๐ŸŒ A tiny and simple global state manager for React

Downloads

302

Readme

โš›๏ธ React store

A minimal, typed, selector-based global state manager for React

React has no shortage of state management librariesโ€”from Redux to Zustand and Jotai. But sometimes all you need is a simple, fast, and tiny way to share state across components โ€” without magic, proxies, or boilerplate.

@odemian/react-store is a minimal global state manager that:

  • Weighs less than 0.5KB
  • Has zero dependencies
  • Is fully type-safe
  • Uses selectors for efficient state reads and updates
  • Based on the new useSyncExternalStore React API

๐Ÿš€ Features

  • โœ… Tiny: ~330 bytes, no dependencies
  • ๐Ÿงผ Clean API: createStore gives you everything you need
  • ๐ŸŽฏ Selectors: read only the data you care about
  • ๐Ÿง  Fully typed: TypeScript support out of the box
  • ๐Ÿ” Reacts to changes: Efficient updates with fine-grained subscriptions
  • โ™ป๏ธ Global shared state: Use in any component

๐Ÿ“ฆ Installation

npm i @odemian/react-store

๐Ÿง‘โ€๐Ÿ’ป Usage

1. Create your store

// stores/userStore.ts
import { createStore } from "@odemian/react-store";

export const [useUser, updateUser] = createStore({
  name: "",
  surname: "",
});

2. Use the store in your component

import { useUser, updateUser } from "./stores/userStore";

export const UserSettings = () => {
  const name = useUser((u) => u.name); // selector-based subscription

  const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    updateUser((curr) => ({ ...curr, name: e.currentTarget.value }));
  };

  return (
    <div>
      <h2>User Settings</h2>
      <label htmlFor="name">User name</label>
      <input id="name" value={name} onChange={onChange} />
    </div>
  );
};

3. Async data fetching

import { useUser, updateUser } from "./stores/userStore";
import { useEffect } from "react";

const fetchUser = () => new Promise<{ name: string; surname: string; }>((r) => {
  setTimeout(() => r({ name: "Hello", surname: "world" }), 1500);
});

export const App = () => {
  const user = useUser();

  useEffect(() => {
    fetchUser().then(updateUser);
  }, []);

  return (
    <div>
      <h2>{user.name} {user.surname}</h2>
    </div>
  );
};

๐Ÿ“˜ API Reference

createStore<T>(initialValue: T): [IStoreHook<T>, TStoreUpdater<T>, TStore<T>]

Creates a global store with the given initial state.

Returns

An index array with:

  • Hook to be used in React components
  • Update function
  • Store get and subscribe methods

๐Ÿ” Hook Usage

const value = useStore()

Returns the full state object (no selector).

const value = useStore(selector)

Reads a selected part of state. Component only rerenders if selected value changes.

Example:

const name = useUser((u) => u.name); // UI render only if name changes, not entire state

๐Ÿ“ Example: Todo App

import { createStore } from "@odemian/react-store";
import { useState } from "react";

export type TTodo = {
  id: number;
  name: string;
  done: boolean;
};

export const [useTodos, updateTodo] = createStore<TTodo[]>([
  { id: Date.now(), name: "First task", done: false },
]);

export const addTodo = (name: string) =>
  updateTodo((todos) => [
    ...todos,
    { id: Date.now(), name, done: false },
  ]);

export const toggleTodo = (id: number) =>
  updateTodo((todos) =>
    todos.map((t) => (t.id === id ? { ...t, done: !t.done } : t))
  );

export const removeTodo = (id: number) =>
  updateTodo((todos) => todos.filter((t) => t.id !== id));

// Components
const CreateTodo = () => {
  const [text, setText] = useState("");

  const onAddTodo = (title: string) => {
    addTodo(title);
    setText("");
  };

  return (
    <div>
      <input
        value={text}
        onChange={(e) => setText(e.currentTarget.value)}
        onKeyDown={(e) => e.key === "Enter" && onAddTodo(text)}
      />
      <button onClick={() => onAddTodo(text)}>Add</button>
    </div>
  );
};

const Todos = () => {
  const todos = useTodos();

  return (
    <div>
      {todos.map((todo) => (
        <div key={todo.id}>
          <input
            type="checkbox"
            checked={todo.done}
            onChange={() => toggleTodo(todo.id)}
          />
          {todo.name}
          <button onClick={() => removeTodo(todo.id)}>Remove</button>
        </div>
      ))}
    </div>
  );
};

export const App = () => (
  <main>
    <Todos />
    <CreateTodo />
  </main>
);

๐Ÿ“ƒ License

MIT