react-qstate
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

React Query State

react-qstate is a simple library that allows states to be saved in url parameters. The benefits can be various:

  • Have the exactly same UI
    • A user can share the link on social and whoever clicks on it will have the same ui
    • Can be saved as a bookmark and will bring back to the same UI
  • You can use the "back" button to go back through the states
  • It can help search engine optimization
  • and more...

Installation

You can install it with your favorite package manger

npm install react-qstate
pnpm add react-qstate
yarn add react-qstate
bun add react-qstate

Usage

Its use is very simple and familiar with the existing useState hook

import { useQueryState } from "react-qstate";

function App() {
  const [count, setCount] = useQueryState("counter", 0);

  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>Click me</button>
    </div>
  );
}

Package Sidebar

Install

npm i react-qstate

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

8.07 kB

Total Files

12

Last publish

Collaborators

  • vclemenzi