# swr-sync-state

> SWR extension to enabled state management using SWR

Latest version **1.0.4** (published 2023-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install swr-sync-state
pnpm add swr-sync-state
yarn add swr-sync-state
bun add swr-sync-state
```

## Health

**Score 40/100 (D)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2023-05-20 |
| First published | 2023-05-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | https://github.com/vikyw89 |
| Maintainers | vikyw |
| Keywords | SWR, state, manager, redux, zustand, use-sync-v, tanstack, query |

## Links

- npm: https://www.npmjs.com/package/swr-sync-state
- Repository: https://github.com/vikyw89/swr-sync-state
- Homepage: https://github.com/vikyw89/swr-sync-state#readme
- Issues: https://github.com/vikyw89/swr-sync-state/issues
- npm.io page: https://npm.io/package/swr-sync-state

## Dependencies (1)

- [swr](https://npm.io/package/swr.md) ^2.1.5

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2023-05-20
- 1.0.3 — 2023-05-19
- 1.0.2 — 2023-05-19
- 1.0.1 — 2023-05-18
- 1.0.0 — 2023-05-18

## README

# swr-sync-state

a small library to wrap SWR, enabling SWR to function as global state manager

## to start

```jsx
npm i swr-sync-state
```

## usage

```jsx
// inside react component
export const SomeComponent = () => {
  const key = 'someKey';
  const state = useSyncSWR(key) ?? 0;

  const incrementHandler = () => {
    setSyncSWR(key, (p) => (p ?? 0) + 1);
  };

  return (
    <div>
      <div>Counter : {state}</div>
      <button onClick={incrementHandler}>Increment</button>
    </div>
  );
};
```

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