# zustand-immer-store

> A ~268B library to create type-safe redux-style stores with Zustand and Immer

Latest version **0.9.6** (published 2023-02-21) · SEE LICENSE IN LICENSE.md license · 0 weekly downloads

## Install

```sh
npm install zustand-immer-store
pnpm add zustand-immer-store
yarn add zustand-immer-store
bun add zustand-immer-store
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.6 |
| Published | 2023-02-21 |
| First published | 2022-01-11 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE.md |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 80.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alan Soares |
| Maintainers | alanrsoares |
| Keywords | state-management, zustand, typescript, immer, redux |

## Links

- npm: https://www.npmjs.com/package/zustand-immer-store
- Homepage: https://github.com/alanrsoares/zustand-immer-store
- npm.io page: https://npm.io/package/zustand-immer-store

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 0.9.6 (latest) — 2023-02-21
- 0.9.5 — 2022-12-30
- 0.9.4 — 2022-06-23
- 0.9.3 — 2022-05-16
- 0.9.2 — 2022-05-16
- 0.9.1 — 2022-05-16
- 0.9.0 — 2022-05-16
- 0.8.2 — 2022-01-24
- 0.8.1 — 2022-01-24
- 0.8.0 — 2022-01-24
- 0.7.0 — 2022-01-24
- 0.6.0 — 2022-01-20
- 0.5.0 — 2022-01-19
- 0.4.1 — 2022-01-19
- 0.4.0 — 2022-01-19
- … 11 more at https://npm.io/package/zustand-immer-store/versions

## README

# Zustand Immer Store

[![npm](https://img.shields.io/npm/v/zustand-immer-store)](https://www.npmjs.com/package/zustand-immer-store)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/zustand-immer-store?style=flat)](https://bundlephobia.com/package/zustand-immer-store)

A ~268B library to create type-safe redux-style stores with [Zustand](https://github.com/pmndrs/zustand) and [Immer](https://github.com/immerjs/immer)

[Live demo on codesandbox](https://codesandbox.io/s/zustand-immer-store-demo-q5xqi)

# Installation

```bash
yarn add zustand-immer-store
```

# Usage

```tsx
// counter-store.ts
import { createStore } from "zustand-immer-store";

const useCounterStore = createStore(
  { counter: 0 },
  {
    createActions: (set) => ({
      increment: () =>
        set((draft) => {
          draft.state.counter++;
        }),
      decrement: () =>
        set((draft) => {
          draft.state.counter--;
        }),
    }),
  }
);

export default useCounterStore;
```

```tsx
// App.tsx
import useCounterStore from "./counter-store";

export default function App() {
  const { state, actions } = useCounterStore();
  return (
    <main>
      <div>
        <button onClick={actions.decrement}> - </button>
        <div>{state.count}</div>
        <button onClick={actions.increment}> + </button>
      </div>
    </main>
  );
}
```

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