How to use experimental broadcastQueryClient
Hey guys, I was looking at the documentation for the broadcast query client plugin: https://tanstack.com/query/latest/docs/framework/react/plugins/broadcastQueryClient, doesn't it require any other setup?
Asking because I am not sure if it is actually working, I would expect that the data in query client is automatically synced between tabs without me having to do something but it is not the case.
2 Replies
ugly-tan•8mo ago
Looking at the source, it shouldn't require any other setup. Are you sure that the origin and broadcast channel are the same in both tabs?
I would expect that the data in query client is automatically synced between tabsI don't think this is correct. Once you call
broadcastQueryClient, any new updated/removed events will be broadcast to all clients. But it will not attempt to sync data that was already in the cache before you called broadcastQueryClient.eastern-cyan•8mo ago
I'll note I did try this plugin and all it took was what you see in the example, but it didn't work well with dependent queries. The tabs kept fighting for the correct query state