Hmph
Hmph
CCConvex Community
Created by Hmph on 4/10/2025 in #support-community
Manually preloading a query in React
Hi, I'm using Convex in a SPA React app. I want to preload the next route's data on mouse hover -- what's the best way to do this? Setup: - Every route has a loader() function. - The loader function returns an object - Components can access the result of the loader with a useLoader() hook. - When a user hovers over a link, the loader() function for that route runs and is cached for x seconds. What's the best way to do this with Convex? Since loader() is not a hook or component, we can't use the useQuery() hook. Is there a Convex-native way to do this (would watchQuery() help?), or should I use a 3rd party async state management library?
2 replies