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

js-queryparams

v4.0.1

Published

A JavaScript library to retrieve the query parameters with cross browser compatibility.

Readme

js-queryparams

A JavaScript library to retrieve the query parameters with cross-browser support.


How to Install:

Inside your project, run the following command:

npm i js-queryparams

The above command will install the js-queryparams module inside the node_modules folder. After this you can either directly refer to the node_modules/js-queryparams/lib/index.js file from within your webpage or extract it and host it in your webserver.


Usage:

Assume the current browser url is:

https://www.example.com/?p1=v1&p2=some=text&p3={"key1":"val1","key2":[1,2,3,4]}&p4=v4&p4=a4&p4=&p5=https://www.example.com&p6=https%3A%2F%2Fwww.example.com%2F%3Fabc%3Ddef%26pqr%3Dxyz&p7=test=01&p8&p9=v9#somehash

The library has the following functions:

queryParams.get(<paramName>);

e.g.:
queryParams.get("p1"); // --> "v1" i.e. a single value.
queryParams.get("p4"); // --> ["v4", "a4", ""] i.e. an Array of values, if the parameter gets repeated in the query string.
queryParams.getAll() 

// Output: 

{
    "p1": "v1",
    "p2": "some=text",
    "p3": "{\"key1\":\"val1\",\"key2\":[1,2,3,4]}",
    "p4": [
        "v4",
        "a4",
        ""
    ],
    "p5": "https://www.example.com",
    "p6": "https://www.example.com/?abc=def&pqr=xyz",
    "p7": "test=01",
    "p8": "",
    "p9": "v9"
}

The queryParams.get and queryParams.getAll functions also support an optional argument to specify a url.

queryParams.getAll("https://www.example.com/?p1=v1&p2=v2")

// Output: 

{
    "p1": "v1",
    "p2": "v2"
}

queryParams.get("p2", "https://www.example.com/?p1=v1&p2=v2")

// Output:

"v2"

In case the reference queryParams needs to be changed, then it can be done as follows:

// queryParams.changeRef(<newRefName>);

// e.g.:
queryParams.changeRef("$qp");
console.log(queryParams); // --> ReferenceError

// use $qp instead of queryParams
$qp.get("p1"); // --> "v1"

Once the reference is changed, the old reference is deleted, so trying to use it will result in a ReferenceError.


License: MIT (https://mit-license.kcak11.com)