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

@haragei/signals

v1.0.0

Published

A lightweight, framework-agnostic TypeScript library for reactive state management.

Readme

@haragei/signals

@haragei/signals is a lightweight, framework-agnostic TypeScript library for fine-grained reactive state.

It provides:

  • signals for reactive state with immutable reads
  • memos for derived state
  • effects for reactive side effects
  • actions for imperative async writes
  • resources for async derived state
  • stores for isolated reactive graphs

Installation

pnpm add @haragei/signals
import { action, batch, effect, memo, resource, signal, subscribe, untracked } from '@haragei/signals';

Quick Start

import { effect, memo, signal } from '@haragei/signals';

const [count, setCount] = signal(0);
const doubleCount = memo(() => count() * 2);

effect(() => {
    console.log(`${count()} x 2 = ${doubleCount()}`);
});

setCount(1);
setCount(2);

Async Example

import { effect, resource, signal } from '@haragei/signals';

type Wallet = { id: string; balance: number };

const walletId = signal('wallet-1');

const [wallet] = resource<Wallet>(async ({ signal }) => {
    const id = walletId.read();
    const response = await fetch(`/api/wallets/${id}`, { signal });
    return response.json();
});

effect(() => {
    const state = wallet();

    if (state.status === 'loading') {
        console.log('Loading wallet...');
    }

    if (state.status === 'ready') {
        console.log(state.value.balance);
    }
});

Action Example

import { action, effect, signal } from '@haragei/signals';

const name = signal('');

const [saveProfile, { submit }] = action(async ({ signal }, timestamp = Date.now()) => {
    const response = await fetch('/api/profile', {
        method: 'POST',
        signal,
        headers: { 'content-type': 'application/json' },
        body: JSON.stringify({ name: name(), timestamp }),
    });

    return response.json() as Promise<{ saved: boolean; name: string }>;
});

effect(() => {
    const state = saveProfile();

    if (state.status === 'pending') {
        console.log('Saving...');
    }

    if (state.status === 'success') {
        console.log('Saved profile for', state.value.name);
    }
});

void submit();

Immutable Reads

Signals can store objects, arrays, and other structured values, but reactive reads are typed as immutable snapshots.

This is intentional: mutating a value returned from read(), untracked(), track(), a memo, or a resource does not notify dependents, so it would break the reactive model.

const [todos, setTodos] = signal([{ title: 'Write docs', done: false }]);

// todos()[0].done = true; // Type error: reads are immutable

setTodos((previous) => {
    return previous.map((todo, index) => (index === 0 ? { ...todo, done: true } : todo));
});

If you want a change to be reactive, compute and write a new value instead of mutating the current one in place.

Core Concepts

Signals

Signals hold reactive state. Reading a signal inside an effect or memo creates a dependency. Updating it re-runs the dependents that use it. Signal reads are typed as immutable, so objects and arrays must be replaced rather than mutated in place.

API reference: docs/api/signals.md

Memos

Memos are derived read-only signals. They recompute automatically when their dependencies change, expose immutable reads, and are best used for idempotent derived values.

API reference: docs/api/memos.md

Effects

Effects react to signal, memo, and resource changes. They support cleanup callbacks, cancellation, async execution, post-await manual dependency tracking via track(), and configurable async concurrency behavior. All values read inside effects follow the same immutable-read contract.

API reference: docs/api/effects.md

Resources

Resources model async derived state. They expose loading, ready, and error states, keep stale values while refreshing, and provide imperative controls such as refresh(), abort(), and reset(). Resource state values and previous snapshots are typed as immutable.

API reference: docs/api/resources.md

Actions

Actions model imperative async write operations such as form submissions. They never run reactively, only when submit() or submitWith() is called, and they expose immutable action state plus submit(), submitWith(), abort(), and reset() controls. submitWith() adds submit-scoped cancellation, while abort() remains action-wide and rolls the visible state back to the last settled result instead of leaving the action stuck in pending.

API reference: docs/api/actions.md

Stores

Stores isolate reactive graphs. The global APIs are convenience wrappers around a default global store, while createStore() lets you construct independent stores explicitly.

API reference: docs/api/store.md

Utilities

The shared runtime utilities cover batching, adapter subscription helpers, untracked reads, and queue primitives used by async effects and resources.

API reference: docs/api/utilities.md

For the full API documentation landing page, see docs/api/README.md.

License

MIT

See Also