# use-param-state

> React hook that works much like useState, but it encodes the state and saves it in a parameter in the URL

Latest version **0.0.10** (published 2022-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-param-state
pnpm add use-param-state
yarn add use-param-state
bun add use-param-state
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.10 |
| Published | 2022-09-03 |
| First published | 2022-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 25.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Herman Wikner |
| Maintainers | hermanwikner |
| Keywords | params, react, state |

## Links

- npm: https://www.npmjs.com/package/use-param-state
- Repository: https://github.com/hermanwikner/use-param-state
- Issues: https://github.com/hermanwikner/use-param-state/issues
- npm.io page: https://npm.io/package/use-param-state

## Dependencies (1)

- [pako](https://npm.io/package/pako.md) ^2.0.4

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.10 (latest) — 2022-09-03
- 0.0.8 — 2022-08-20
- 0.0.7 — 2022-08-20
- 0.0.6 — 2022-08-20
- 0.0.5 — 2022-08-19
- 0.0.4 — 2022-08-19
- 0.0.3 — 2022-08-19
- 0.0.2 — 2022-08-19
- 0.0.1 — 2022-08-19

## README

## useParamState

React hook that works much like `useState`, but it encodes the state and saves it in a parameter in the URL.

### Installation

`yarn add use-param-state` or `npm i use-param-state`

### Usage

The hook accepts an object as a prop with the following properties:

- `initialState?: <T>` – The initial state
- `key: string` – The URL parameter key for the encoded state

```ts
import {useParamState} from 'use-param-state'

const [state, setState] = useParamState<string>({
  initialState: 'Hello world',
  key: 'myKey',
})
```

---
_Source: https://npm.io/package/use-param-state · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
