DaRealPheyeeD
Convex Community2y ago
2 replies
DaRealPheyee

Clerk + Convex Identifier Recommendation

Hello!

I have a question regarding an identifier for Clerk in the database.

Clerk has 2 different ways of identifying users and it doesn't seem to be consistent in a way.

When using the currentUser() hook, it returns tokenIdentifier and subject. The tokenIdentifier is a combination of the clerk url and the subject.

However, when getting data using Clerk webhook, it returns a unique identifier named "id" which is the same as the value of the subject identifier.

My question now is: Which of this is recommended to use as a unique identifier in my Convex database so I can easily map Clerk users to their data in the database.

I was thinking of storing both the tokenIdentifier and subject/id but it might not be a good practice.

Lastly, the reason why i am asking this is because when performing queries or mutations on the database, i will mostly need to locate a specific user in the DB and it must be done using an identifier.

Thanks in advance.
Was this page helpful?