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

@sigrea/use

v0.2.1

Published

Framework-agnostic Sigrea utilities for signals, scopes, and browser APIs.

Readme

@sigrea/use

@sigrea/use provides framework-agnostic Sigrea utilities built on @sigrea/core signals and scopes. It is intended for shared state, timing, watcher, and browser logic that should not depend on Vue, React, or a template runtime.

  • Framework-agnostic utilities. Use signal-powered helpers without binding to a UI framework.
  • Scope-aware cleanup. Browser listeners, timers, workers, and observers can be cleaned up through Sigrea scopes.
  • SSR-safe imports. Browser-dependent helpers avoid touching browser globals during module import.
  • Tree-shakable package. ESM and CJS entrypoints are generated from the same TypeScript source.

Table of Contents

Install

npm install @sigrea/use @sigrea/core

@sigrea/core is a peer dependency.

Requires Node.js 24 or later.

Quick Start

import { useCounter, useEventListener, useMediaQuery } from "@sigrea/use";

const counter = useCounter(0, { min: 0 });
const isWide = useMediaQuery("(min-width: 768px)");

const resize = useEventListener("resize", () => {
  if (isWide.matches.value) {
    counter.inc();
  }
});

// Later, when this listener is no longer needed:
resize.stop();

See the exported utility groups below and the function docs for function-specific behavior.

Event-Driven Molecules

Use createEvents when a molecule needs to send typed events to a parent or controller molecule. For controlled values, use update:* event names such as update:open, update:value, or update:selectedValue; the event segment matches the controlled prop, while local boolean state can use names such as isOpen.

send() resolves after registered listeners finish. Listeners registered in a Sigrea scope are removed when that scope is disposed, including listeners registered during molecule setup.

See createEvents for the full pattern.

API Overview

@sigrea/use exports utilities for common browser and reactivity work:

  • State and signals: counters, toggles, async state, memoization, and signal transforms.
  • Watchers and timing: debounced, throttled, pausable, ignorable, one-shot, and triggerable watchers.
  • Browser APIs: media queries, storage, events, clipboard, network, sensors, observers, workers, and page state.
  • Collections and math: array helpers, projections, clamping, precision, averages, sums, and numeric transforms.

All utilities are exported from the root package entrypoint.

Testing

Most utilities can be tested as plain TypeScript functions with Vitest. For browser APIs, use JSDOM-compatible fakes and stop returned handles in the test that created them.

Handling Scope Cleanup Errors

For global error handling configuration, see @sigrea/core - Handling Scope Cleanup Errors.

When a utility registers cleanup through a Sigrea scope, cleanup errors are reported through the core handler. Configure the handler once in the application entry point or test setup before creating scoped utilities.

Development

This repo targets Node.js 24 or later.

If you use mise:

  • mise trust -y — trust mise.toml (first run only).
  • pnpm -s cicheck — run CI-equivalent checks locally.
  • mise run notes — preview release notes (optional).

You can also run pnpm scripts directly:

  • pnpm install — install dependencies.
  • pnpm test — run the Vitest suite once (no watch).
  • pnpm typecheck — run TypeScript type checking.
  • pnpm test:coverage — collect coverage.
  • pnpm build — compile via unbuild to produce dual CJS/ESM bundles.
  • pnpm -s cicheck — run CI checks locally.

See CONTRIBUTING.md for workflow details.

License

MIT. See LICENSE.