Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding adding the user attribute to the session, is this document wrong? #12716

Open
fengyufuchen opened this issue Feb 27, 2025 · 0 comments
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@fengyufuchen
Copy link

What is the improvement or update you wish to see?

  1. https://authjs.dev/getting-started/session-management/get-session?framework=next-js
  2. https://authjs.dev/guides/extending-the-session
  3. https://authjs.dev/getting-started/typescript?framework=next-js

I want to add an address property to the user property in session, refer to the third link document


export const { auth, handlers } = NextAuth({
  callbacks: {
    session({ session, token, user }) {
      // `session.user.address` is now a valid property, and will be type-checked
      // in places like `useSession().data.user` or `auth().user`
      return {
        ...session,
        user: {
          ...session.user,
          address: user.address,
        },
      }
    },
  },
})

My question is does the session function accept user as an argument in the following code?

The call to session in source code is

// @ts-expect-error
const newSession = await callbacks.session({ session, token });

No user attribute

Is there any context that might help us understand?

https://authjs.dev/getting-started/typescript?framework=next-js

Does the docs page already exist? Please link to it.

No response

@fengyufuchen fengyufuchen added the triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

1 participant