Best practice for setting global state on login #2650
Replies: 2 comments 4 replies
-
I am not sure what you are asking here. What do you mean by "not quickly enough"? You usually use the See: |
Beta Was this translation helpful? Give feedback.
-
That is interesting - I wonder if the cache is causing me trouble. I am storing an array of ids for user favourites that I persist to the database, this is loaded into the session so I can show them. I think it would be better on login to make a query to load these into a separate state/provider rather than relying on nextauth session. My question is, when can I make a client-side call on successful login to populate the state? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
Hi there. I was storing user data in the session, but it isn't updated quickly enough for my use case and therefore probably a bad way to have user state for my app. I want to store data from the database in a global state and manipulate it there - this would load once the user has logged in. I cannot work out where this should be done - where using nextauth is the sensible place to make a db call and update state upon login and only then?
How to reproduce ☕️
Something like this - but not sure where the best place in the app life cycle is. I appreciate this isn't a perfect git issue, but I hope you get the gist of what I am asking.
Contributing 🙌🏽
No, I am afraid I cannot help regarding this
Beta Was this translation helpful? Give feedback.
All reactions