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

@usels/core

v0.2.1

Published

Observable-native React utility hooks for Legend-State, inspired by VueUse and react-use

Readme

@usels/core

Observable-native React utility hooks for Legend-State.

Inspired by VueUse and react-use, @usels/core brings the same composable utility philosophy — but built from the ground up for observable-first reactivity. Every hook returns Legend-State observables instead of using useState, enabling fine-grained updates without re-rendering the entire component tree.

Installation

npm install @usels/core@beta @legendapp/state react
# or
pnpm add @usels/core@beta @legendapp/state react

Quick Example

import { useRef$, useElementSize } from '@usels/core';

function SizeDisplay() {
  const el$ = useRef$<HTMLDivElement>();
  const size$ = useElementSize(el$);

  return (
    <div ref={el$} style={{ resize: 'both', overflow: 'auto', padding: 16 }}>
      {size$.width.get().toFixed(0)} × {size$.height.get().toFixed(0)}
    </div>
  );
}

size$.width and size$.height are observables — only the expressions that read them re-render, not the component.

Hooks

Elements

| Hook | Description | |------|-------------| | useRef$ | Observable element ref — the foundation of @usels/core | | useElementSize | Track element dimensions reactively | | useElementBounding | Track element bounding rect | | useElementVisibility | Observe whether an element is visible in the viewport | | useIntersectionObserver | Reactive IntersectionObserver wrapper | | useResizeObserver | Reactive ResizeObserver wrapper | | useMutationObserver | Reactive MutationObserver wrapper | | useMouseInElement | Track mouse position relative to an element | | useDraggable | Make an element draggable | | useDropZone | Create a drop zone for drag-and-drop | | useDocumentVisibility | Track document.visibilityState | | useParentElement | Get the parent element as an observable | | useWindowFocus | Track window focus state | | useWindowSize | Track window dimensions |

Timer

| Hook | Description | |------|-------------| | useFps | Track frames per second | | useInterval | Reactive counter on interval | | useIntervalFn | Run a function on interval with pause/resume | | useNow | Reactive Date.now() | | useRafFn | Run a function on every requestAnimationFrame | | useTimeAgo | Reactive relative time string (e.g. "3 minutes ago") | | useTimeout | Reactive timeout state | | useTimeoutFn | Run a function after timeout with controls | | useTimestamp | Reactive timestamp with configurable interval |

Browser

| Hook | Description | |------|-------------| | useEventListener | Auto-cleaning event listener that reacts to observable element refs | | useMediaQuery | Reactive CSS media query matching |

Sensors

| Hook | Description | |------|-------------| | useScroll | Track element scroll position | | useWindowScroll | Track window scroll position |

Utilities

| Hook | Description | |------|-------------| | get | Unwrap a value that may or may not be an observable | | peek | Peek at an observable value without tracking | | usePeekInitial | Get the initial value of an observable without subscribing | | useSupported | Check browser API support as an observable | | useWhenMounted | Run logic only after component mount |

Features

  • Observable-native — every hook returns Legend-State observables, not useState
  • Fine-grained reactivity — only the expression reading the observable re-renders
  • Reactive element refsuseRef$ provides observable refs that hooks react to automatically
  • Tree-shakeable — import only what you need
  • TypeScript — full type safety
  • ESM & CJS — supports both module systems

Peer Dependencies

| Package | Version | |---------|---------| | @legendapp/state | ^3.0.0-beta.0 | | react | ^18.0.0 \|\| ^19.0.0 |

Links

License

MIT