StoicWandererS
Convex Community3y ago
2 replies
StoicWanderer

Auth error while using useQuery

Hello Convex users and Team,

My setup is Convex with Clerk authentication. I have a sign-up rpocess after which the use is being redirected to /rules page, inside which I have this piece of code:
const agreedCheck = useQuery(api.users.readUserById).

I am also using Next.js, which shows me the error, that the Convex function, getUserIdentity doesn't return any logged in users, although i followed every setup piece on both Convex and Clerk, so after sign-up there must be at least one user logged in, according to Clerk.

The error comes up even after refreshing the page or after redirecting the user from the sign-up page or after signing out with Clerk's Userbutton component(afterSignOutUrl="/").

My question is, that how should i use this Hook? is it called even when being defined as before I mentioned it, at least it seems that the useQuery hook calls my Convex function as early as being defined, like this:
const agreedCheck = useQuery(api.users.readUserById).

How can i solve this?
Was this page helpful?