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

@trosckey/url-params

v2.4.1

Published

Class for working with URL query string (uses URL.searchparams interface under the hood)

Downloads

9

Readme

url-params

Makes your work with search params in URL easy.

Instead of:

const url = new URL(window.location.href)
url.searchParams.set("hello", "world")
url.searchParams.set("test", "123")
window.location.href = url.toString()

you can do this:

urlParams
  .set("hello", "world")
  .set("test", "123")

or even this:

urlParams.setAll({
  hello: "world",
  test: 123
})

ci npm publish

Table of Contents

Browser support

Chrome | Firefox | Safari | Opera | Edge | --- | --- | --- | --- | --- | 49 | 44 | 14 | 36 | 17 |

Installing

Using npm:

npm install @trosckey/url-params

Using yarn:

yarn add @trosckey/url-params

Usage

Methods delete, set and append returns this for
call chain. To get URL string you can use instance
property url or toString().

If first argument is not defined, window.location.href will be used.

urlParams('https://github.com')
  .set('hello', 'world')
  .append('hello', 'web')
  .url // https://github.com?hello=world&hello=web

Creating an instance

import { URLParams } from '@trosckey/url-params'

new URLParams('https://github.com')
  .set('hello', 'world')
  .get('hello') // "world"

Using urlParams function

import { urlParams } from '@trosckey/url-params'

urlParams('https://github.com')
  .set('hello', 'world')
  .get('hello') // "world"

Using urlParams Proxy

creates instance on every call, uses window.location.href

import { urlParams } from '@trosckey/url-params'

// window.location.href = 'https://github.com'

urlParams
  .set('hello', 'world')
  .get('hello') // "world"

Import minified version

import {
  URLParams,
  urlParams
} from '@trosckey/url-params/dist/index.min.js'

// ...

new URLParams().url

// ...

urlParams().url

// ...

urlParams.url

API

saveSate(default false) - using window.history.pushState
instead of window.history.replaceState

replaces window.location.href if none
of methods above is not available

url

Returns url string

set(name, value[, saveState])

Sets value with the given key

urlParams('https://github.com')
  .set('hello', 'world')
  .set('hi', 'web')
  .url // https://github.com?hello=world&hi=web

setAll(properties[, saveState])

Sets many values from object

urlParams('https://github.com')
  .setAll({
    hello: "world",
    hi: "web",
  })
  .url // https://github.com?hello=world&hi=web

append(name, value[, saveState])

Appends value with the given key

urlParams('https://github.com')
  .append('hello', 'world')
  .append('hello', 'there', true)
  .url // https://github.com?hello=world&hello=there

get(name)

Returns first searched item from left, otherwise null

urlParams('https://github.com?hello=world&hello=there')
  .get('hello') // "world"

urlParams('https://github.com')
  .get('hi') // null

getAll(name)

Returns all values of query param in array

urlParams('https://github.com?hello=world&hello=there')
  .getAll('hello') // ["world", "there"]

urlParams('https://github.com')
  .getAll('hello') // []

getAllParams()

Returns all query params in two-dimensional array

urlParams('https://github.com?hello=world&hello=there&test=123')
  .getAllParams() // [["hello", "world"], ["hello", "there"], ["test", "123"]]

delete(name[, saveState])

Deleting query param from url

urlParams('https://github.com?hello=world')
  .delete('hello')
  .url // https://github.com

toString()

Returns url string, can be used for auto cast to string

License

MIT