#Svelte: server side: call queries?

1 messages · Page 1 of 1 (latest)

quasi jetty
#

How can I call convex functions: queries, mutations, etc... from +page.server.ts from the load: PageServerLoad function?

According to the docs, I need to add to +layout.svelte the following code: setupConvex(PUBLIC_CONVEX_URL); which is done.

But as soon as I add const sessionJson = useQuery(api.auth.user.validateSession, { sessionId: sessionCookie }); into my load function I get the error:

Svelte error: lifecycle_outside_component
getContext(...) can only be used during component initialisation

exotic nova
#

useQuery is for components, not loaders

quasi jetty
#

@exotic nova thank you, it's helped!