You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello devs, I am following the official documentation on how to extend the session object. I noticed during development that every time I signIn a new user.id is being generated (even when signing in using the same account; in this case a GitHub account). Is this normal AuthJS behavior? Thanks.
auth.ts
importNextAuthfrom'next-auth'importgithubfrom'next-auth/providers/github'exportconst{ handlers, signIn, signOut, auth }=NextAuth({providers: [github],callbacks: {jwt({ token, user }){if(user){// User is available during sign-intoken.id=user.id// new user id being generated upon sign in, idk why}returntoken},session({ session, token }){session.user.id=token.idasstringreturnsession},},})
sign-in.tsx
import{signIn}from'@/auth'import{Github}from'lucide-react'import{Button}from'./ui/button'exportdefaultfunctionSignIn(){asyncfunctionsignInWithGithub(){'use server'awaitsignIn('github')}return(<formaction={signInWithGithub}><ButtonclassName="flex justify-center gap-2"type="submit"><Github/> Sign in with GitHub
</Button></form>)}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello devs, I am following the official documentation on how to extend the session object. I noticed during development that every time I
signIn
a newuser.id
is being generated (even when signing in using the same account; in this case a GitHub account). Is this normal AuthJS behavior? Thanks.auth.ts
sign-in.tsx
sample output
then, upon a sign out and sign in with the same account:
Beta Was this translation helpful? Give feedback.
All reactions