A module to get query string parameters from the window object

Usage no npm install needed!

<script type="module">
  import patomationQueryParam from 'https://cdn.skypack.dev/@patomation/query-param';


Query Param Module

Gets query string parameters from window location substring.


yarn add @patomation/query-param
npm install @patomation/query-param --save


import { queryParam } from '@patomation/query-param'

const myParams = queryParam()

Example url might be:


Result is one json object:

//  myParams =
  make: 'Tesla',
  model: 'T',
  year: 2019,
  electric: true

localStorage support

You can set a query param with this. It will be persisted in local storage. So when you redirect and go to a different page the param will be present.

import { localStorageQueryParam } from '@patomation/query-param'

const myParams = localStorageQueryParam()


  1. navigate to page one with the param
//  pageOne params =
  cool: 'beans'
  1. navigate to page two without the query string. The param will still exist in local storage
//  pageTwo params =
  cool: 'beans'

The local storage key is 'persist:queryParam'

Additional notes

  • white spaces converts %20 to white space