How alok-shete/beru works
Beru is a lightweight React and React Native state-management library. An application creates a store, updates it directly or through actions, and React components subscribe to the whole state or selected values. Optional middleware persists state and supports hydration, while a separate DevTools integration records changes and handles time-travel commands. The graph covers the sampled runtime modules and README capabilities; persistence setup beyond the sampled implementation is shown only where documented, not as an inspected call path.
Main entry points: persist.ts State persistence · index.ts DevTools integration · store.ts Store and actions · hooks.ts React store hooks
Components 13
State management
- Store and actions
src/core/store.ts - In-memory state
src/core/store.ts - Public API
src/index.ts
React subscriptions
- React store hooks
src/core/hooks.ts - Selector subscription
src/utils/useSyncExternalStoreWithSelector.native.ts - Platform selector entry
src/utils/useSyncExternalStoreWithSelector.ts
Optional middleware
- State persistence
src/middleware/persistence/core/persist.ts - Hydration coordinator
src/middleware/persistence/core/setupHydrator.ts - DevTools integration
src/middleware/devtools/index.ts
Shared internals
- Shared utilities
src/utils/common.ts
Other components
- Application code
- Configured storage
- Redux DevTools
Connections 15
- Application code → Public API: imports API
src/index.ts - Public API → Store and actions: exports create
src/index.ts - Store and actions → In-memory state: holds state
src/core/store.ts - Store and actions → React store hooks: uses hooks
src/core/store.ts - Application code → React store hooks: subscribes in components
README.md - React store hooks → Platform selector entry: selects snapshots
src/core/hooks.ts - Platform selector entry → Selector subscription: delegates on web
src/utils/useSyncExternalStoreWithSelector.ts - Application code → State persistence: opts into persistence
- State persistence → Configured storage: reads and writes
src/middleware/persistence/core/persist.ts - Hydration coordinator → State persistence: hydrates stores
src/middleware/persistence/core/setupHydrator.ts - DevTools integration → Redux DevTools: connects and sends
src/middleware/devtools/index.ts - DevTools integration → In-memory state: updates store
src/middleware/devtools/index.ts - State persistence → Shared utilities: uses fallbacks
src/middleware/persistence/core/persist.ts - Hydration coordinator → Shared utilities: runs tasks
src/middleware/persistence/core/setupHydrator.ts - DevTools integration → Shared utilities: logs errors
src/middleware/devtools/index.ts