Minimal Immer-first local state for React applications with one root state tree, immutable snapshot reads, and synchronous atomic writes.
pnpm add immili react immerimmili expects react and immer 8 or newer to be installed by the consuming app.
import { createActions, createStateTree, useActions, useStateTree } from 'immili'
const AppState = createStateTree({
counter: { value: 1 },
})
const AppActions = createActions(AppState, (draft) => ({
counter: {
increment() {
draft.counter.value++
},
},
}))
export function Counter() {
const state = useStateTree(AppState)
const actions = useActions(AppActions, state)
return (
<button onClick={() => actions.counter.increment()}>
{state.counter.value}
</button>
)
}- Conceptual model and recommended patterns: docs/context.md
- Canonical usage example: examples/basic-react.tsx
- Exact exported signatures: dist/index.d.mts