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

use-entity

v0.1.1

Published

Fast, typed entity state for React with CRUD actions and selectors.

Readme

use-entity

Fast, typed entity state for React with minimal boilerplate. It gives you consistent CRUD operations for normalized collections, plus a ready-to-use hook and selector helpers that stay portable across state managers. Powered by Redux Toolkit's createEntityAdapter.

Why it’s useful:

  • useState-like API for collections with CRUD actions.
  • CRUD-first API for collections (add, update, remove, upsert) with strong typing.
  • TanStack Store integration (see docs).
  • Normalized data with built-in selectors (all, ids, entities, byId, total).

Install

npm install use-entity

Quick Start (React useState)

import { useStateEntity } from "use-entity";

type User = { id: string; name: string; age: number };

export function Users() {
    const [users, actions] = useStateEntity<User>();

    const addUser = () =>
        actions.addOne({ id: String(Date.now()), name: `User ${users.length + 1}`, age: 20 });

    const birthday = (user: User) =>
        actions.updateOne({ id: user.id, changes: { age: user.age + 1 } });
    
    return (
        <div>
            <button onClick={addUser}>Add user</button>
            <ul>
                {users.map((user) => (
                    <li key={user.id}>
                        <span>
                            {user.name} ({user.age})
                        </span>
                        <button onClick={() => birthday(user)}>+1 age</button>
                        <button onClick={() => actions.removeOne(user.id)}>Remove</button>
                    </li>
                ))}
            </ul>
        </div>
    );
}

Actions

All actions mirror Redux Toolkit's entity adapter API (docs):

addOne, addMany,
setOne, setMany, setAll,
removeOne, removeMany, removeAll,
updateOne, updateMany,
upsertOne, upsertMany

Selectors

useEntity() and useStateEntity() default to the "all" selector, which returns the array of items. You can opt into other selectors (including the full selector object) and access byId. (Based on rtk docs)

Selector options:

all: T[];
ids: string[];
entities: Record<string, T>;
total: number;
full: {
  all: T[];
  ids: string[];
  entities: Record<string, T>;
  total: number;
  byId: (id: string) => T | undefined;
};

Usage:

const [all] = useStateEntity<User>([], "all");
const [ids] = useStateEntity<User>([], "ids");
const [entities] = useStateEntity<User>([], "entities");
const [total] = useStateEntity<User>([], "total");
const [full] = useStateEntity<User>([], "full");

const user2 = full.byId("2");

Notes

  • T must include id: string (number as id is not yet supported).

Releases

This repo uses Changesets.

  1. For any user-facing package change, run bun run changeset and commit the generated file in .changeset/.
  2. When changesets reach main, GitHub Actions opens or updates a release PR with the version bump and generated CHANGELOG.md.
  3. Merge the release PR to publish.