5 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
When integrating Better Auth with Convex in my Next.js app, after signing in with Better Auth, the Convex authentication state (useConvexAuth()) remains stuck in isLoading. As a result, isAuthenticated never becomes true, and any authenticated queries or mutations (e.g., useQuery(api.auth.getCurrentUser, isAuthenticated ? {} : "skip")) are never executed. The UI always shows the unauthenticated state, even though the sign-in with Better Auth succeeds and a token is issued.
I have verified that:
The provider configuration in auth.config.ts is correct and the domain matches.
The Better Auth client is initialized with the convexClient() plugin.
The Convex client is set up with ConvexBetterAuthProvider and the correct URL.
The versions of convex, @convex-dev/better-auth, and better-auth match the recommended ones.
There are no errors in the browser or server logs.
Despite this, Convex never recognizes the authentication, and the app is stuck in a loading or logged-out state. This prevents any authenticated queries from running, as documented in the official guides Basic Usage: Authorization.
Is there a known issue or additional configuration required to get Convex to recognize the Better Auth session and resolve the authentication state?
You probably have
expectAuth: true on your Convex client - this pauses all queries from initial execution until the user is authenticated. Turn that off to troubleshoot what's happening with auth.Yes, I have it, but I also tested without it. Queries restart, but authentication still doesn't occur
I'm currently using the better auth session hook, to determined whos currently signed in.
Does this conflict with telling, if the user is currently authenticated with convex.
Is betterauth session != convex authenciation?