Advanced Clerk Stuff in Convex
I assume if you want to createUsers, validate if a user exists in Clerk etc. inside of Convex you have to use the clerk-sdk-node. Right?
11 Replies
Yes, I would assume so.
Ok, I just wanted to make sure that convex does not have its own implementation of that.
Hi, I tried both the @clerk/backend and @clerk/clerk-sdk-node and both give me this error if I call my (ent) mutation

Code:
and code for @clerk/backend:
Those clerk sdk functions are trying to make network calls, which can only be made through actions (not queries or mutations).
oh, thank you
Would be nice to have an error for that. Something like Error: Tried to make a network request inside the mutation. Try to use an action.
Yeah I agree - if you open another support post with that request and add the Feature Request label the team can track it
Is it the right way to use the scheduler for outsourcing the clerk code to an action?
You're using the data returned from Clerk in your mutation so you would need to kick this off with an action that gets the data from clerk and then uses
ctx.runMutation()
to run the mutation, passing in the received data.
That said, actions are not as reliable as queries or mutations, so the recommended approach is to maintain a users table in your Convex db and sync data to it from Clerk. That will allow you to do all of this in Convex with using an action."with using an action?"
if I maintain the users also in convex i don't need the action anymore, right?
oh sorry, I meant "without using an action"
right, wouldn't be needed