Sharing state between browser tabs
ptrhck opened this issue · 4 comments
How can global state shared between browser windows with overmind?
Currently, I check if the user has logged in but opening a new tab redirects to the login page.
Is that related to SSR? I am using Next.js static site generation with apollo client, so completely client side.
Is there any example on sharing state between windows?
This sounds like more of a persistence problem rather than an overmind problem - how are you storing the login? If you open a new tab you open a new instance of the page - all JS re-runs, therefore overmind re-inits, etc.
If you are using something like AWS Amplify for example, then this sort of thing is easily solvable by calling the right action on persisted login, i.e.:
Auth.currentUserInfo().then(user => if(user.isLoggedInSomehow) actions.setUserLogin(true); else actions.setUserLogin(false) }
Closing this but reopen if needed