preloading + persist plugin
Hi guys
I’ve been exploring TanStack Start and ran into an issue when trying to use the tanstack query persist plugin.
When I use
useQuery like this, it works as expected — the query is persisted, and if the data already exists, it doesn’t re-fetch from the API.
but If I try to preload the query using ensureQueryData, it always calls the API again regardless, ignoring the persisted data on the client.
i expected it dosn't call the api again if the data already exists on client ? right ?
also useSuspenseQuery triggers an api call too .. ignoring the persisted data .. only useQuery works fine without preloading5 Replies
flat-fuchsia•3mo ago
have you setup the start-query integration properly?
xenial-blackOP•3mo ago
yes i followed the documentation .. its not something with my setup
i think this is me misunderstanding how tanstack start works
the issue only happens on first render .. which happens on server and it dosn't know anything about my client state
and i guess the next route navigations run on client so tanstack start is aware about my client state and it doesn't trigger another api call
.. but i'm still confused why this still happens even with { ssr : false } ?
even with spa mode enabled .. idk
correct-apricot•3mo ago
can you provide a complete minimal example project ?
correct-apricot•3mo ago
Try to
await itflat-fuchsia•3mo ago
pretty sure ensureQueryData always calls the queryFn
the reason its not running again on client is precisely because its already there
and the fact that you have a staleTime of infinity