Luke
Luke14mo ago

Access Clerk Organization in Query

I am authenticating users in my app via Clerk and can easily query for Clerk userId when making requests via ctx.auth. However I want to link an entity in my DB to Clerk Organizations and I don't have that information readily available in the Convex environment/context. Is there a recommended approach to this from within Convex? The way I am thinking now is either fetching via Clerk in the frontend and passing it to the query each time or duplicating all of the Clerk data in Convex, but I'm not too keen on that.
3 Replies
Michal Srb
Michal Srb14mo ago
Hey Luke, you have two options: 1. Use webhooks, like in this template: https://www.convex.dev/templates/clerk 2. Use an unused JWT field, like "gender", to pass the orgId through the JWT to ctx.auth.getUserIdentity()
Templates
The backend application platform with everything you need to build your product.
Luke
LukeOP14mo ago
OK thanks for getting back to me, I will look into it The webhook approach seems to have worked for me, thanks
Michal Srb
Michal Srb7mo ago
Custom claims are now supported with convex@1.14.0

Did you find this page helpful?