Caveats with passing the load
-fetch
into script
for SSR?
#7034
Unanswered
MoritzKronberger
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hi Moritz, Sorry, I think I am misunderstanding something. Is there an error if you use a normal |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
A bit of background:
I am using SvelteKit with tRPC and Svelte Query and I am trying to get credentialized server-side requests to work. Svelte Query's
useQuery
must strictly be used on component initialization so I can't use the usual approach of running the queries inside thefetch
function.The workaround I found, has been to instantiate the tRPC client using the
load
function'sfetch
in my root-+layout.ts
and accessing the client from thePageData
prop in my pages.My question:
Since the
load
function'sfetch
is not available inside the page's/layout'sscript
by default (please correct me if this is wrong), I was wondering if there are any potential issues/concerns with passingfetch
into the pagescript
?Beta Was this translation helpful? Give feedback.
All reactions