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-context-selectors

v0.1.0

Published

Call multiple useContextSelector hooks with one tuple-typed API.

Readme

use-context-selectors

Call several useContextSelector hooks in one expression, with tuple-typed results that line up with your selectors.

This package re-exports the full public API of use-context-selector. It is a peer dependency, so you install it alongside this package — that way you control the version and avoid duplicate copies in your bundle.

Installation

pnpm add use-context-selectors use-context-selector
# or: npm install use-context-selectors use-context-selector

Peer dependencies: React 18+, scheduler 0.19+, and use-context-selector 2+.

pnpm add react scheduler

In many apps, scheduler is already satisfied transitively (for example via react-dom). If the bundler reports a missing scheduler module, add it explicitly.

Usage

Import context helpers from this package, then pass a context and one or more selectors to useContextSelectors. You get an array of selected values in the same order as the selectors, with types inferred from each selector’s return type.

import { createContext, useContextSelectors } from "use-context-selectors";

type Store = { count: number; label: string };

const StoreContext = createContext<Store>({ count: 0, label: "" });

function Counter() {
  const [count, label] = useContextSelectors(
    StoreContext,
    (s) => s.count,
    (s) => s.label,
  );

  return (
    <button type="button">
      {label}: {count}
    </button>
  );
}

That is equivalent to calling useContextSelector once per selector, but keeps selectors and results grouped and easier to refactor.

Re-exports

Everything exported by use-context-selector is also re-exported from use-context-selectors (for example createContext, useContextSelector, useContext, useContextUpdate, BridgeProvider, useBridgeValue). You can import those symbols from either package — both resolve to the same installed copy of use-context-selector.

API

useContextSelectors(context, ...selectors)

  • context — A Context created with createContext from this package (or the same API as upstream).
  • selectors — One or more functions (value) => selected where value is the context’s current value.

Returns: A tuple (array) whose element types are the return types of the selectors, in order.

Each selector still runs under the same rules as upstream: the component re-renders only when the selected slice changes (by Object.is).

ContextType<C>

Utility type: the value type held by a given context C (the infer partner to your context generic).

import type { Context, ContextType } from "use-context-selectors";

declare const MyContext: Context<MyState>;

type State = ContextType<typeof MyContext>;

Development

This repo uses Vite+ (vp).

  • Install dependencies: vp install
  • Format, lint, and typecheck: vp check
  • Tests: vp test
  • Build the library: vp pack

License

MIT