This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

use-search-param
TypeScript icon, indicating that this package has built-in type declarations

2.3.1 • Public • Published

use-search-param

A React hook to safely and easily read from URL search params.

version bundle size downloads per week package quality license dependencies


Docs for version 1.4.4 (the last version before version 2.0.0) can be viewed here


⚠️ Warning: this package is deprecated! ⚠️

Docs for version 2.3.0 (the last version before being deprecated) can be viewed here

As an alternative, use use-search-param-state:

import { useSearchParamState } from "use-search-param-state";

function Demo() {
  const [counter] = useSearchParamState("c", 0);
}

All of the options from use-search-param:

interface Options<TVal> {
  sanitize?: (unsanitized: string) => string;
  parse?: (unparsed: string) => TVal;
  validate?: (unvalidated: unknown) => TVal | null;
  onError?: (error: unknown) => void;
  serverSideSearchParams?: string;
}

are still supported, though note that serverSideSearchParams is updated to serverSideURLSearchParams: URLSearchParams in use-search-param-state

Why deprecate?

Prior to use-search-param-state v3.0.0, useSearchParamState required being wrapped in a context provider: SearchParamStateProvider. For cases where setting the state wasn't necessary, use-search-param provided a simpler alternative with the same API - but without a provider wrapping your app.

In v3.0.0, use-search-param-state was refactored to remove the need for a context provider. Without a provider, there's no longer a significant difference between use-search-param-state and use-search-param, and no reason to maintain both libraries.

Package Sidebar

Install

npm i use-search-param

Weekly Downloads

21

Version

2.3.1

License

MIT

Unpacked Size

19.2 kB

Total Files

14

Last publish

Collaborators

  • elanmed