# @hoeks/use-persisted-state-sync

> The [hoeks](https://github.com/onursagir/hoeks) `usePersistedStateSync` hook. Persist your state variable into the browsers localStorage(sync). Made with TypeScript

Latest version **1.0.1** (published 2021-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hoeks/use-persisted-state-sync
pnpm add @hoeks/use-persisted-state-sync
yarn add @hoeks/use-persisted-state-sync
bun add @hoeks/use-persisted-state-sync
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-01-25 |
| First published | 2021-01-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 229.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | onursagir |

## Links

- npm: https://www.npmjs.com/package/@hoeks/use-persisted-state-sync
- npm.io page: https://npm.io/package/@hoeks/use-persisted-state-sync

## Recent versions

- 1.0.1 (latest) — 2021-01-25
- 1.0.0 — 2021-01-25

## README

# @hoeks/use-persisted-state-sync

The [hoeks](https://github.com/onursagir/hoeks) `usePersistedStateSync` hook. Persist your state variable into the browsers localStorage(sync). Made with TypeScript

## Installation

```bash
$ yarn add @hoeks/use-persisted-state-sync
$ npm i --save @hoeks/use-persisted-state-sync
```

## Usage

It's similar to the React.useState hook. The only difference is that you provide a second argument being the key which will be use to save the state in localStorage. It also returns a 3rd function which allows you to clear the localStorage

### Example

```javascript
import * as React from 'react';
import usePersistedStateSync from '@hoeks/use-persisted-state-sync';

const Example: React.FunctionComponent = () => {
  const [count, setCount, clear] = usePersistedStateSync(1, 'example');

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

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