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

@nexus-state/family

v0.1.6

Published

> Utilities for working with state "families" in Nexus State — dynamic atom collections > > [![npm version](https://img.shields.io/npm/v/@nexus-state/family)](https://www.npmjs.com/package/@nexus-state/family) > [![Coverage for family package](https://cov

Readme

@nexus-state/family

Utilities for working with state "families" in Nexus State — dynamic atom collections

npm version Coverage for family package License

DocumentationRepository


📦 Installation

npm install @nexus-state/family

Required:

npm install @nexus-state/core

🔗 See Also

Full ecosystem: Nexus State Packages


Description

@nexus-state/family provides utilities for creating and managing dynamic collections of related atoms using atom families. It allows you to generate individual atoms based on runtime parameters (e.g., IDs), enabling efficient management of lists, entities, and other dynamic state structures.

What is atomFamily?

atomFamily is a pattern for dynamically generating atoms based on parameters. Instead of creating many static atoms (like user1Atom, user2Atom, etc.), you can create a single factory function that generates atoms as needed.

For example:

const userFamily = atomFamily((userId) => atom({ id: userId, name: "" }));
>
> [![Coverage for family package](https://coveralls.io/repos/github/eustatos/nexus-state/badge.svg?branch=main&job_name=family)](https://coveralls.io/github/eustatos/nexus-state?branch=main)
const user1Atom = userFamily(1); // Creates an atom for user ID 1
const user2Atom = userFamily(2); // Creates an atom for user ID 2

Each generated atom is independent, allowing for isolated state management per entity.

Benefits

  • Dynamic Atom Creation: Generate atoms on demand based on parameters (e.g., IDs).
  • State Isolation: Each atom maintains its own state without interfering with others.
  • Efficient Caching: Reuses atoms for the same parameters.
  • Scalability: Ideal for managing lists, profiles, caches, and UI elements with individual state.

Common Use Cases

  • Managing lists of entities (e.g., todos, users, posts).
  • Per-ID caching strategies.
  • UI components with independent states (e.g., collapsible panels, forms).

Installation

npm install @nexus-state/family

Usage Example

import { atom } from "@nexus-state/core";
import { atomFamily } from "@nexus-state/family";

// Create an atom family for managing todos
const todoFamily = atomFamily((id) =>
  atom({
    id,
    text: "",
    completed: false,
    createdAt: new Date(),
  }),
);

// Create atoms dynamically
const todo1Atom = todoFamily(1);
const todo2Atom = todoFamily(2);

// Use atoms in your store
store.set(todo1Atom, { id: 1, text: "Buy milk", completed: false });
const todo1 = store.get(todo1Atom);

API

atomFamily(createAtom)

Creates an atom family function.

Arguments

  • createAtom: (param: any) => Atom<T> — A function that creates an atom based on the provided parameter.

Returns

  • (param: any) => Atom<T> — A function that returns an atom for a given parameter.

Example

const userFamily = atomFamily((userId) => atom({ id: userId, name: "" }));
const userAtom = userFamily("user123");

License

MIT