clerk metadata
hello guys i never use clerk before and still using nextauth, the reason is if we use nextauth db strategy and i change something in user session while the user is still online, lets say i change the role directly in db, the user session automaticly change. if we using jwt strategy the user need to logout first and got the new session.
in clerk i see people using the metada to insert their role, and we can update it, the question is what if the user is online using our app, and we want to update their metadata to differnt role, do we need to make the user logout first or it will automaticlly change, if yes im gladly migrate to Clerk😁
Thanks!
7 Replies
You can attach metadata to a user’s session in Clerk. Then, you can call user.reload() to fetch the updated session data. Check out their docs for implementation details
so its not automaticlly changing the session even when we use the updateUser function?
It updates the backend but to my knowledge you have to refresh the session on the client using something like user.reload()
This is correct, if you update the metadata, we need the session to be updated..This is because the client doesn't know you have made changes to the backend data.
The first is
user.reload()
which automatically updates the session and the user data.
The other is to wait for the session token to be refreshed which is every 50 seconds..ahhh that good info, but i think i need more guidance, soo what the best time to use the user.reload function in client
UPDATE: i decided to try migrate to clerk, but another problem comes up how to set user metadata when they first signup?
any ideas guys?
do i need to use webhook?
any idea why this return not a function :(((
Webhooks or you can redirect to a form after sign up, depends on how you want to handle it