Skip to content

Official Plugins

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

Install

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

Available plugins

PluginDescription
persistPersist state to localStorage (or any custom storage)
historyUndo / redo / reset with snapshot history
immerWrite reducers as Immer draft mutations

Usage pattern

All plugins are applied with .use(). Namespaced plugins (like persist and history) expose their methods under their namespace key:

ts
import { withPlugins } from '@kin-store/core'
import { persist, history, immer } 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) },
    },
  }))

store.dispatch.add('hello')
store.history.undo()
await store.persist.hydrate()

Released under the MIT License.