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

stateful-params

v1.1.2

Published

A lightweight and intuitive React hook for managing URL query parameters with ease. Stateful-params enables seamless CRUD operations on URL query parameters while keeping your UI in sync with the URL state. Perfect for building dynamic, stateful, and shar

Readme

stateful-params

A lightweight and intuitive React hook for managing URL query parameters with ease. Stateful-params enables seamless CRUD operations on URL query parameters while keeping your UI in sync with the URL state. Perfect for building dynamic, stateful, and shareable UIs without the hassle of manual URL manipulation.

Features

  • Stateful URL Management: Automatically reflects changes in the URL and keeps your app state in sync.
  • CRUD Operations: Easily create, read, update, and delete URL parameters.
  • Lightweight: Minimal footprint, maximum utility.
  • Dynamic UIs: Simplify building UIs that depend on URL parameters.

Installation

Install the package using npm:

npm install stateful-params

Usage

Basic Example

import { useStatefulParams } from "stateful-params"

const MyComponent = () => {
  const { set, get, deleteParam, append, searchParams } = useStatefulParams<{
    filter: string
    sort: string
    tags: string[]
  }>()

  const handleSetParam = () => {
    set({ filter: "active", sort: "asc" })
  }

  const handleAppendParam = () => {
    append({ tags: ["react", "hooks"] })
  }

  const handleDeleteParam = () => {
    deleteParam("filter")
  }

  return (
    <div>
      <h1>Current Params: {JSON.stringify(searchParams)}</h1>
      <button onClick={handleSetParam}>Set Params</button>
      <button onClick={handleAppendParam}>Append Params</button>
      <button onClick={handleDeleteParam}>Delete Param</button>
      <p>Filter: {get("filter") || "Not set"}</p>
    </div>
  )
}

API Documentation

useStatefulParams(options)

A hook for managing URL query parameters with options to update the router.

Parameters

  • options (optional): Configuration options.
    • deleteFalseValues (boolean, default: true): Whether to delete the parameter if the parameter value is a false value.
    • method ("replace" | "push", default: push): Method to use for router update.

Returns

An object containing the following methods and properties:

  • set(params): Sets multiple query parameters at once.

    • params: An object containing parameter key-value pairs to set.
    • Returns the new query string after setting the parameters.
  • append(params): Appends values to existing query parameters or adds new ones.

    • params: An object containing parameter key-value pairs to append.
    • Returns the new query string after appending the parameters.
  • deleteParam(keys): Removes specified query parameters.

    • keys: The key or array of keys to remove from the query parameters.
    • Returns the new query string after deleting the specified parameters.
  • clear(): Clears all query parameters.

    • Returns the new query string after clearing all parameters.
  • get(key): Retrieves the value of a specified query parameter.

    • key: The key of the query parameter to retrieve.
    • Returns the value of the specified query parameter, or null if not found.
  • searchParams: An object representation of the current query parameters.

Example Use Cases

  • Filtering and Sorting: Persist filter and sort states in the URL for shareable links.
  • Dynamic UIs: Build UIs that react to URL changes, such as tabs or modals.
  • Pagination: Manage pagination state in the URL for better navigation.

Contributing

Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

@Ahmed Hassan