Custom Auth With Kinde
I am working on a Nextjs project with Kinde for authentication and Convex for my backend. I am implementing custom auth by integrating Kinde. I have created my own custom auth provider to use with Kinde. The convex client seems not to fetch the JWT token although setAuth is called on the convex client. I get a null response when trying to log the user's identity to the client while a user is logged in.
What am I doing wrong here?
4 Replies
convex
needs to be outside the ConvexProviderWithAuth
component (in module scope): Otherwise you get a new Convex client on every render;
useKindeBrowserClient
needs to be inside useAuthFromKinde
hook implementation, otherwise it's not a real hook and won't react to the changes from Kinde's client.Thanks for the feedback. I have done what you suggested but the JWT token is still not being fetched by the convex client.
I would suggest console.log inside the hook to debug what's going on. You can also pass {verbose: true} to the ConvexReactClient constructor to get more info.
We also have https://docs.convex.dev/auth/debug with more general auth debugging instructions that might be helpful.
Debugging Authentication | Convex Developer Hub
You have followed one of our authentication guides but something is not working.
Hey,
Using the useKindeBrowserClient hook to access the isAuthenticated auth data inside the ConvexProviderWithKinde when signed in returns false but returns true when used in a different component when logged to the console.
I would appreciate any explanation of why this happens and possible ways to resolve this issue.
The instructions in the docs does not cover this issue.