query-params-data

A React, Typescript, and Parcel boilerplate

Usage no npm install needed!

<script type="module">
  import queryParamsData from 'https://cdn.skypack.dev/query-params-data';
</script>

README

query-params-data

Actions Status

Easily control data in query params.

  • set data at a specific query param
  • subscribe to changes of data at different query param keys.

Usage

import UrlStore from 'query-params-data';

// control the `user_id` query param
const userIdUrlStore = new UrlStore('user_id');

// set data to the `user_id` query param
userIdUrlStore.setState('1');

// subscribe to changes of the `user_id` query param or get the existing state at startup
const onChange = state => console.log(`The current user id is ${state}`);
userIdUrlStore.subscribeToStateChanges(onChange);