create-t3-app next auth question
In the default auth settings for t3, I noticed
id: token.sub
in the callbacks making the id available on the user object. Is this sub
something I can use as my unique user/account id in my db? What is sub?
Solution:Jump to solution
Yes, unless you change it, as per https://github.com/nextauthjs/next-auth/discussions/6695
GitHub
JWT sub property · nextauthjs next-auth · Discussion #6695
Question 💬 I am currently working on Nextjs project and using nextAuth for authentication . right now whenever any user completes sign in then the JWT generated has sub property which always contai...
7 Replies
Solution
Yes, unless you change it, as per https://github.com/nextauthjs/next-auth/discussions/6695
GitHub
JWT sub property · nextauthjs next-auth · Discussion #6695
Question 💬 I am currently working on Nextjs project and using nextAuth for authentication . right now whenever any user completes sign in then the JWT generated has sub property which always contai...
So if someone signs in with apple, google, or custom credentials, they will all be given that unique id in
sub
that won't be changed unless I change it?Im not sure what you are asking. A sign in using apple would be a new user even if a google account exists with the same email linked to it. If that is what you are asking
yes, thank you 🙏
NextAuth has no way of know if a person in real life has multiple accounts on different services. Im not even sure how it would know that. That's why they are all distinct
i just wanted to make sure the sub would be unique and never change (other than by me) so that it would be ok to use that as the unique identifier for my users
Allright, please mark the question as solved by the way