Svelte: server side: call queries?
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 initialisation4 Replies
@GhostBob something like this? https://github.com/get-convex/convex-svelte/blob/main/src/routes/%2Bpage.server.ts
useQuery is for components, not loaders
@ballingt thank you, it's helped!
And to make it "global" use a server hook...