-
Hi i was wondering if some one can help me at explain me ho to sync datas in a store between multiple tabs, preferably with an example. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
You just need to search the internet about that. There are multiple possibilities for communication. |
Beta Was this translation helpful? Give feedback.
-
Just searched for "zustand broadcast channel" and found https://github.com/Tom-Julux/shared-zustand. |
Beta Was this translation helpful? Give feedback.
-
Yep, i foudn that too yesterday but as I read in the docs it's in a very primordial state but it can be useful as an example an take some inspiration to do something better, thanks @dai-shi, may be i can start thinking o writing some code to integrate to zustand in order to let users do this kind of things without do that from scratch, what do you think? |
Beta Was this translation helpful? Give feedback.
-
does anyone know if there is a ready-to-use library to achieve client-side state synchronization using Zustand and Websockets ? on the lines of https://blog.armanddu.com/real-time-app-with-react-and-web-sockets-part-2/ |
Beta Was this translation helpful? Give feedback.
-
#1614 (comment) |
Beta Was this translation helpful? Give feedback.
-
It's actually easy to write a middleware for this: Middleware:
Usage:
I've also made this into a npm package here: (zero dependencies) Usage:
Demo: https://zustand-sync.netlify.app/ |
Beta Was this translation helpful? Give feedback.
You just need to search the internet about that. There are multiple possibilities for communication.
And none of them directly relates to the zustand. So I believe that your question is out of scope.