Closed Coder-Vasen closed 1 year ago
This issue just seems to be a side-effect of the way that @tanstack/svelte-query
works, rather than an issue with this plugin. The queryClient
is only available to those components that are wrapped with the QueryClientProvider
context and since the +layout.svelte
is the root of all these components, it does not have access to the query client.
One way to get around this would be to simply setup the root +layout.{svelte,ts}
files as in the Tanstack Query docs and create a layout group at the root level which will be ignored in the actual URL with your business logic, somewhat like this:
src/routes
├── (root)
│ ├── +layout.svelte
│ ├── +layout.ts
│ └── +page.svelte
├── +layout.svelte
└── +layout.ts
This works because while (root)
is at the top-level as far as the app is concerned, it is still nested under the root +layout.svelte
and has access to the query client.
Yeah this method works perfectly. Thanks for the help :)
When I am accessing CreateQuery in
+layout.svelte
it is showing an error of No QueryClient in svelte context. In addition I am not able to access the CreateServerQuery result in+layout.svelte
. I am using trpc-sveltekit by @icflorescu. Here is the code