Uncaught Error: Unauthenticated at handler
I'm using NextJS with Clerk.
Every time I do logout with the Clerk
<UserButton />
I get this error:
Uncaught Error: Unauthenticated at handler.
It happens in one screen where I'm making a query, what I imagine it happens is that in Signout I lost the session, and the query is there trying to fetch data, and it fails, but I'll expect the redirect to happen first. Is there a way to fix this?
This is my Provider:
This error happens too when I stop the server, run it again, and reload. And if I reload the page once more it works. supper weird.
Any recommendations are appreciated, thanks.4 Replies
Just to confirm that you also followed step 12 from this walkthrough: https://docs.convex.dev/auth/clerk#nextjs
Those
<Authenticated>
and <Unauthenticated>
wrappers are what control whether or not your pages that contain the Convex queries will render.Convex & Clerk | Convex Developer Hub
Integrate Clerk authentication with Convex
So I fixed it in the dumbest way possible.
And that's it, no more errors hahaha
Fwiw this is absolutely the correct and intended approach
Good to see I'm not as lost as I imagine 😂