Creating logout as next-auth?
Hey, so I was wondering how I could achieve something like next-auth logout/signout?
I have a simple project that just stores a jwt token as a cookie. And I want it to be just like in next-auth, where you log out in one chrome tab, then it automatically logs out in any other open chrome tab.
Could anyone explain to me how they achieve this?
9 Replies
Why don't you just clear the cookie?
Would that also logout on other chrome tabs instant?
sure if it's the same chrome instance
I don't really see how. In the video below, I used the swr auth example, because it was already set up. But shouldn't that then log me out on the other chrome tab instant?
Here's the link for the example:
https://codesandbox.io/s/swr-auth-vl653w?from-embed=&file=/pages/index.js:418-427
the page needs to reload
I don't really know if you mean this. But I added
window.location.reload()
, and it still dosen't logout on the other browser.Ummm so I might not be right like have a wrapper along ur component that use useffect to fetch the cookies so that when ever the cookies get cleared it redirect the person back to login
so you want it to be realtime?