TanStack Query: sync query invalidations across tabs
ArticleTanStack Query
dev.to
To keep views consistent across tabs, this article recommends broadcasting only the query key to invalidate, then letting each tab fetch its own data with its own filters, authentication, and error handling. The example uses BroadcastChannel and a listener mounted once near QueryClientProvider.
Invalidation marks matching queries stale; only active queries refetch immediately. The same mechanism can signal a logout, but the server remains responsible for revoking the session: a closed or frozen tab may miss the message.
