Skip to content

Official Plugins

Official plugins for @kin-store/core, published as @kin-store/plugins.

To learn how to write your own plugin, see Writing Plugins.

Install

sh
npx jsr add @kin-store/plugins
sh
pnpm add jsr:@kin-store/plugins
sh
deno add jsr:@kin-store/plugins

Available plugins

PluginDescription
broadcastSyncs state across browser tabs with BroadcastChannel
devtoolsConnects to the Redux DevTools Extension
historyUndo / redo / reset with snapshot history
immerWrites reducers or set's updaters as Immer draft mutations
persistPersists state to localStorage (or any custom storage)

Usage pattern

All plugins are registered with .use(). Plugins can be top-level or namespaced. Namespaced plugins (like persist and history below) expose their methods under their namespace key:

ts
import { withPlugins } from "@kin-store/core";
import { history, immer, persist } from "@kin-store/plugins";

const store = withPlugins({ todos: [] as string[], count: 0 })
  .use("persist", persist({ key: "my-store" }))
  .use("history", history({ limit: 50 }))
  .use(immer({
    reducers: {
      add: (draft, text: string) => {
        draft.todos.push(text);
      },
    },
  }));

await store.persist.hydrate();
store.history.undo();
store.dispatch.add("hello"); // From the top-level inline plugin

Released under the MIT License