T
TanStack3y ago
fascinating-indigo

Any guidance / examples on react-query + handling live websocket events?

Hey react-query community, we're working on an application that will have a live-updating list of items. We are currently using react-query alongside cursor-based pagination + infinite queries to fetch data. However, we want to also integrate with websocket events (new item, delete item, modify item, etc.) so that we don't need to constantly refetch (polling). We want to be cautious to not produce bugs with duplicate items, missing items, or malformed data in general. Is there any guidance or good code examples for this scenario? Thank you! :reactquery:
2 Replies
fascinating-indigo
fascinating-indigoOP3y ago
I am aware of TkDodo's blog post on this, which is excellent: https://tkdodo.eu/blog/using-web-sockets-with-react-query But I'm curious if the meta has shifted at all since it was written, and I'm curious what's considered best practice for these dynamic cases with a lot of adds/deletes/updates.
Using WebSockets with React Query
A step-by-step guide on how to make real-time notifications work with react-query
fascinating-indigo
fascinating-indigoOP3y ago
Bumping this. Would appreciate guidance on this. Thank you!

Did you find this page helpful?