How to preserve netlify identity state between page changes

Following the example it seems that each page has it’s own window.netlifyIdentity instance. If you logout on home page how do you detect you are logged out if you advance or go back to another page using the browser back/forward arrows?

This would be possible in a SPA, but I’m assuming, you’re having a website with each HTML page exported separately?

You’ll have to use popstate event:

And check for Identity stuff in that function. Since this event is not-cancellable, you’ll have to redirect using JavaScript if needed.

Thanks. I ended up using localStorage as the solution. pushState() and popstate are weird!