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

@kimdw-rtk/react-search-params

v0.1.4

Published

[![NPM](https://img.shields.io/npm/v/@kimdw-rtk/react-search-params)](https://www.npmjs.com/package/@kimdw-rtk/react-search-params)

Readme

@kimdw-rtk/react-search-params

NPM

한국어

Type-safe utilities for managing URLSearchParams in React.

  • Optimizes runtime performance by running only minimal validation.
  • Reduces re-renders by subscribing only to the keys you need.
  • SSR support.

Installation

pnpm add @kimdw-rtk/react-search-params
npm install @kimdw-rtk/react-search-params
yarn add @kimdw-rtk/react-search-params

Usage

Define Schema

export const searchParamsSchema = createSearchParamsSchema<{
  query: string;
  page: number;
  tags: string[];
}>({
  defaultValue: {
    query: '',
    page: 1,
    tags: [],
  },
  skipValidation: false, // Set this to `true` when param changes caused by developer code are sufficiently guaranteed by TypeScript checks, so calls to `validate` can be minimized.
  arrayParams: ['tags'], // For array-type params, you must explicitly specify the keys in `arrayParams`.
  validate: (params) => {
    const page = Number(params.page);

    if (!Number.isInteger(page) || page < 1) {
      throw new Error('page must be a positive integer');
    }

    return {
      query: String(params.query),
      page,
      tags: params.tags?.map(String) ?? [],
    };
  },
});

You can define the validate function manually, but using zod.parse is recommended.

Schema.toString(params)

const result = searchParamsSchema.toString({
  query: 'q',
  page: 1,
  tags: ['a', 'b'],
});
console.log(result); // query=q&page=1&tags=1,2

Converts an object that matches the schema into a URL query string. See the notes below before using it in a URL.

Create Store

export const store = createSearchParamsStore({
  serializer: Serializer.delimiter(','),
});

You usually do not need to create multiple store instances. Be careful not to create multiple store instances accidentally.

Serializer

Choose a serializer based on how arrays are represented in the URL.

Serializer.delimiter(',')

a=1,2

Serializer.repeated()

a=1&a=2

Set & Get Params

export function SearchPage() {
  const [params, setParams] = store.useAllParams(searchParamsSchema);

  return (
    <button
      onClick={() => {
        setParams(
          {
            query: 'react',
            tags: ['javascript', 'typescript'],
          },
          { history: 'pushState' },
        );
      }}
    >
      apply
    </button>
  );
}

Partial Subscribe

const [{ page }, setParams] = store.useParams(searchParamsSchema, ['page']);

You can subscribe to only a subset of keys defined in the schema.

Use in SSR

export default async function Page({
  searchParams,
}: {
  searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
  return (
    <SearchParamsProvider value={await searchParams}>
      <ButtonA />
    </SearchParamsProvider>
  );
}

Use SearchParamsProvider to provide initial URLSearchParams values in SSR.

Notes

This library assumes URLSearchParams changes flow through useParams or useAllParams, and it keeps the internal store in sync based on that assumption.

If URLSearchParams changes outside those hooks, such as through soft navigation, the change may not be detected automatically.