Convex TanStack Query Integration
That looks reasonable! Check out the one we wrote a while ago: https://docs.convex.dev/client/tanstack-query https://github.com/get-convex/convex-react-query
3 Replies
Can you say more about your goals here, why async interables?
omg, how did I miss this 🤦🏽♂️
So the only goal here was to leverage Tanstack's caching so I can store query results in storage and provide results while a device is offline.
I originally stumbled across an article mentioning useLocalQuery but that doesn't seem to be available so I went down the rabbit whole and thought local cache wasn't currently available.
I took a look at oRPC's approach and saw they were using async iterables to keep the query alive while updating the cache so the initial thought was to just replicate their approach, but this is much more straightforward and elegant 💯
Well, at least I learned something 🙂
I'm new to Convex and the development speed I'm getting out of this is pretty mind-blowing 🤯 thanks for pointing me to this!!!
I'd love to see this used with query results in storage! We may be missing useful primitives for this that could be added. See #local-sync for the current status of a more cohesive local feature but I think combining convex with tanstack query (and I'd like to see TanStack DB collections!) is a pragmatic way to do things now.