# react-use-persistent-state

> A react hook that stores your states to `LocalStorage`. It uses the `localforage` module to get and set the value.

Latest version **1.0.3** (published 2020-11-10) · 0 weekly downloads

## Install

```sh
npm install react-use-persistent-state
pnpm add react-use-persistent-state
yarn add react-use-persistent-state
bun add react-use-persistent-state
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-11-10 |
| First published | 2020-07-24 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | watchdict |

## Links

- npm: https://www.npmjs.com/package/react-use-persistent-state
- npm.io page: https://npm.io/package/react-use-persistent-state

## Dependencies (1)

- [localforage](https://npm.io/package/localforage.md) ^1.9.0

## Recent versions

- 1.0.3 (latest) — 2020-11-10
- 1.0.2 — 2020-07-24
- 1.0.1 — 2020-07-24
- 1.0.0 — 2020-07-24

## README

A react hook that stores your states to `LocalStorage`. It uses the `localforage` module to get and set the value.

Example:
````
const TestComponent = () => {
  const defaultValue = 1;
  const [value, setValue, hydrated] = usePersistentState(
    "storageKey",
    defaultValue
  );
  return <div onClick={() => setValue(value + 1)}>{value}</div>;
};
````

The `hydrated` variable is to check whether the hook has retrieved the stored value from `LocalStorage` on initial mount.

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