Dealing with session expiration in a React app
I need to have the UI reflect the logged in state at all times. useSession will not trigger if a session expires (see: https://discord.com/channels/1288403910284935179/1353810672458403920/1353820038154551469)
I'm trying to figure out how to deal with this, here's my current plan:
(tagging this with Next.js but I think it should apply to all React apps)
I'm trying to figure out how to deal with this, here's my current plan:
- Store the current session in a React context. Keep it updated for sign in / sign out via useSession.
- When I get a 401 back from my server, that probably means the session has expired, call getSession and update the context.
(tagging this with Next.js but I think it should apply to all React apps)