streamlined electron state management
tldr: I want to use Zustand in my Electron app, seamlessly
Zustand is a great state management library. As with other state libraries such as Redux, it is recommended that a single store is used in your app.
For Electron apps this is an awkward problem as you need access to the store in both the main and renderer processes.
Zutron enables a single store workflow with Zustand in Electron apps, effectively simplifying the use of Zustand in this context by abstracting away the necessary IPC and dispatch management.
Zutron uses an additional Zustand store in the renderer process, this store is synchronized in one direction with your application store in the main process.
Actions from the renderer process are dispatched across IPC to the main process store, which handles them and updates state accordingly. The renderer store then receives these state updates over IPC and updates itself accordingly.
useStore
hookuseDispatch
hookdispatch
helperSee the docs.
There are minimal example applications featuring three different Zustand usage patterns:
This project would not exist without Reduxtron, shout out to vitordino for creating it!