Official Plugins
Official plugins for @kin-store/core, published as @kin-store/plugins.
Install
sh
npx jsr add @kin-store/pluginssh
pnpm dlx jsr add @kin-store/pluginssh
deno add jsr:@kin-store/pluginsAvailable plugins
| Plugin | Description |
|---|---|
persist | Persist state to localStorage (or any custom storage) |
history | Undo / redo / reset with snapshot history |
immer | Write 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()