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

refilterable

v1.0.0-alpha.10

Published

<div align="center" markdown="1">

Readme

"batteries-included" library to manage URL filters in React-based apps. Uses hooks

Table of Contents

The problem

You want to have stable, reusable URL filters in your React app. As part of this goal, you want to make sure your existing URL filters are not impacted by your new solution. Ideally, you also want to standardize all your interaction with URL filters once and then just refer to existing patterns when you need to add a new filter. Next, you want to make sure you have access to certain filter from any component in your codebase. Plus, you want to make sure small changes in the URL don't cause the whole tree of React components to rerender. Finally, you want to be able to set filters both from your JavaScript code and <a> or react-router <Link> tags. All this has to be dead simple so you can focus on your app instead of reinventing the wheel.

This solution

refilterable offers a simple two-step approach to the problem. You first define what URL parameters you're going to handle and then use a hook that gives allows you to access and mutate those parameters. You can also compose multiple filters into groups, which will allow you to batch mutations. The hook will cause your component to rerender only when the URL parameters relevant to the component change. It will also protect your component from values that are invalid – naturally you'll define what invalid means to you.

Example

// Range.jsx
import { createFilter, composeFilters, useFilter } from 'refilterable';

const minFilter = createFilter('min', {
  parse: (input) => parseInt(input),
  format: (value) => String(value),
  defaultValue: 0,
  validate: (input, parse) => parse(input) >= 0,
});

const maxFilter = createFilter('max', {
  parse: (input) => parseInt(input),
  format: (value) => String(value),
  defaultValue: 100,
  validate: (input, parse) => parse(input) >= 0,
});

const rangeFilter = composeFilters([min, max], ({ min, max }) => min <= max);

export function RangeInput() {
  const [min, setMin] = useFilter(minFilter);
  const [max, setMax] = useFilter(maxFilter);

  return (
    <div>
      Min: <input type="number" onChange={setMin()} />
      Max: <input type="number" onChange={setMax()} />
    </div>
  );
}

export function Range() {
  const [range, setRange] = useFilter(rangeFilter);

  return (
    <div>
      Min: {range.min}
      Max: {range.max}
      <button onClick={() => setRange({ min: 0, max: 100 })}>Set [0-100]</button>
    </div>
  );
}

// App.jsx
import { FiltersProvider, useReset } from 'refilterable';

const history = createBrowserHistory();

function App() {
  return (
    <FiltersProvider history={history}>
      <form>
        <RangeInput />
        <Range>
      </form>
    </FiltersProvider>
  );
}

Installation

This module can be installed via npm or yarn and should be installed as one of your project's dependencies:

npm install --save refilterable
yarn add refilterable

This library has peerDependencies listings for react and history.