|
I’m exploring if it makes sense to use data loaded by TanStack Router’s loaders to initially hydrate TanStack DB collections. Since loaders run on both server and client (for initial load and navigations), can loader data be effectively used to jump-start collections without conflict? Or are loaders and collections two separate data-fetching layers that don’t integrate well (for now)? |
Answered by
thruflo
Jul 3, 2025
Replies: 1 comment 3 replies
|
Yup, this makes total sense and is something we'll be illustrating in the docs and examples. You can see some existing discussions here: https://github.com/search?q=repo%3ATanStack%2Fdb+preload&type=issues End goal is something like: const query = createCollection(liveQueryOptions(...))
export default createFileRoute({
loader: () => query.preload()
})
function Component () {
const { data } = useLiveQuery(query)
} |
3 replies
Answer selected by
superxiao
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yup, this makes total sense and is something we'll be illustrating in the docs and examples.
You can see some existing discussions here: https://github.com/search?q=repo%3ATanStack%2Fdb+preload&type=issues
End goal is something like: