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

feat(react): getSession #3601

Closed
wants to merge 1 commit into from

Conversation

inshatan
Copy link
Contributor

Reasoning 💡

The changes cover following issues:

When retrieving session on the client with the method getSession it is reasonable to update the data stored in the context

Checklist 🧢

  • Documentation
  • Tests
  • Ready to be merged

Affected issues 🎟

Fixes #596
Fixes #2208

@github-actions github-actions bot added client Client related code core Refers to `@auth/core` labels Jan 10, 2022
@balazsorban44
Copy link
Member

getSession is intended to be an isomorphic method that works both client and server-side, and likely won't have the capability to update the state, as it is often used outside of React lifecycle methods even on client-side. For that, please rely on useSession, and well, on the server-side this wouldn't make sense anyway.

@inshatan
Copy link
Contributor Author

inshatan commented Jan 11, 2022

getSession is intended to be an isomorphic method that works both client and server-side, and likely won't have the capability to update the state, as it is often used outside of React lifecycle methods even on client-side. For that, please rely on useSession, and well, on the server-side this wouldn't make sense anyway.

Thank you for the quick reply)

The proposed changes will remain getSession isomorphic.

About the issues - currently, you should reload the page to update the session. It is inappropriate in a lot of cases.

There is a workaround: #596 (comment). But this workaround will not work when a user is unauthenticated (__NEXTAUTH.session = null).

Please provide some mechanism to trigger session reload/update programmatically. I can help you with implementation if it is necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Client related code core Refers to `@auth/core`
Projects
None yet
2 participants