Replies: 2 comments 3 replies
-
Hi, I'm not sure but the docs seem to suggest you can't:
Could you use https://tanstack.com/query/latest/docs/framework/svelte/ssr#using-prefetchquery |
Beta Was this translation helpful? Give feedback.
-
Yep, with I don't know I'm afraid. This example is from Tanstack Router which does support doing that. But it may not directly translate across to Sveltekit's load function. It shows you can prefetch data without waiting for it: export const Route = createFileRoute('/issues/$issueId')({
loader: ({ context: { queryClient }, params: { issueId } }) => {
void queryClient.prefetchQuery(issueQuery(issueId))
},
component: Issues,
}) ... then you'd handle the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How can I prefetch queries in svelte kit?
The first issue i faced is passing the queryClient from +page.server.ts like this;
but I get this error from sveltekit "Cannot stringify arbitrary non-POJOs (data.queryClient)" so I have to create the client in the page component...
My plan was to use it in another +page.server.ts like this;
but since i cannot pass the queryClient i can't do that, and if I pass the client in the component i can't access in in the second +page.server.ts to prefetch.
any help with this would be appreciated, thanks.
Beta Was this translation helpful? Give feedback.
All reactions