Skip to content

Middleware bridging zustand stores between isolated Electron contexts

License

Notifications You must be signed in to change notification settings

rallyspace/zustand-ipc-bridge

Repository files navigation

zustand-ipc-bridge

Middleware to bridge zustand stores between isolated Electron contexts.

Demo

Fiddle Button

Usage

npm install zustand-ipc-bridge

Main

import { create } from "zustand";
import { ipcMiddleware } from "zustand-ipc-bridge/main";

const mainStore = createStore(ipcMiddleware(storeCreator));

Preload

import { contextBridge } from "electron";
import { createZustandBridge } from "zustand-ipc-bridge/preload";

contextBridge.exposeInMainWorld("zustandBridge", createZustandBridge());

Renderer

import { create } from "zustand";
import { ipcMiddleware } from "zustand-ipc-bridge/renderer";

const store = create(ipcMiddleware(storeCreator, zustandBridge));

Roadmap

  • Support more than 1 store. Bridged events are not scoped to a specific store, so only 1 store can be bridged right now.
  • Typing. Everything is typed as any right now.

About

Middleware bridging zustand stores between isolated Electron contexts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published