#Invalidate query doesn't work with beforeLoad query?
17 messages · Page 1 of 1 (latest)
prefetching should still work
you need to useQuery on the client to use the prefetched data
your main issue is passing down the data with eg fetchQuery which is just a static payload thats sent to the component
your existing code will just work when you use router.invalidate() btw as it reruns loaders
router = useRouter() for example
prefetchQuery returns nothing cause it just preloads data so your useQuery hook has it right away without fetching it.
https://tanstack.com/query/latest/docs/framework/react/guides/prefetching for prefetching info
scroll down to the router segment
its really intuitive
yep and invalidating the single query key should make the useQuery hook refetch
with router / start you just pass the props down which is way nicer
beware that beforeLoad runs for every segment (eg if that page you open within the layout route is /dashboard/account, it runs for pathless, dashboard and account)
loader is what runs for the exact route component
you may want to deduplicate these calls
this is a good read: https://www.anchortags.dev/posts/tanstack-start-loaders-explained
A practical guide to TanStack Start's two loader functions: when they run, how data flows, and what you need to know about serialization.
if you’re using better-auth , https://better-auth-ui.com/components/organization-settings-cards this package has pre built components for account and organisation management.