Identity seems flaky (I'm often partially logged-out)

From what I can tell, the Identity JS library and the server-side Identity logic often do not agree on whether I’m logged in or not.

I don’t have a 100% lead on the issue (and I am a developer, so I’m used to looking for these things). The symptoms I’m seeing are:

  • The JS library often thinks I’m logged in (renders the “log out” message), but the page content that is served suggests the server doesn’t agree. (I’m bounced via redirect to the login page.)
  • Logging out and logging sometimes, but not always, helps the situation.
  • Deploying a new version of the site often seems to induce this situation.

Is this a known issue? Is there anything I can do to help understand this situation?

hi there, @scouten :wave:

Thanks for reaching out. It looks like this thread has been quiet since you last wrote in-- thanks for your patience.

I haven’t seen any other reports of this, so I appreciate you bringing this up. Has this occurred again since you last wrote in? Does this happen on every machine / browser you use?

@scouten ,

Sorry for the hold-up. In short, the only thing I can think of is the one hour expiration on JWTs. You’ll want to check out this lengthy discussion for more!


Thank you, that discussion did help immensely.

My situation is slightly different than the OP in that thread I’m not trying to protect a JS application, but rather purely static content, so I do really need to rely on RBAC to protect the underlying content.

There’s a very minimal layer of JS in my content and the critical piece that I learned from that thread (and had missed from other documentation) was that I need to have the browser refresh the token periodically. I’ve added this to my SSG template and it seems to be helping:

    window.netlifyIdentity.on('login', (user) => {
      window.netlifyIdentity.refresh(true).then(() => {

    window.netlifyIdentity.on('logout', (user) => {
      window.location.href = '/login';

    window.netlifyIdentity.init({ container: '#netlify' });

(Cross fingers; it’s still early days …)