GhostBobG
Convex Community17mo ago
5 replies
GhostBob

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 initialisation
image.png
Was this page helpful?