javascriptlocal-storage

Inter-tab localStorage value propagation changed behavior


I recently noticed that localStorage.getItem() in one tab immediately reflects changes made by localStorage.setItem() in another tab, without requiring a storage event listener. I'm seeing this behavior in both Chrome and Firefox. This appears to be a recent change - my code worked correctly until around November 2025.

The Problem:

I use a BroadcastChannel to notify tabs when a user changes. Each tab runs this code when notified:

checkIfUserChanged(user: User) {
  let currentUserSub = user.profile.sub;
  let previousUserSub = localStorage.getItem(this.user_change_key);
  if (currentUserSub !== previousUserSub) {
    localStorage.setItem(this.user_change_key, currentUserSub);
    window.location.href = AppConstants.webRoot;
  }
}

Previously: When Tab A changed users and updated localStorage, Tab B's localStorage.getItem() would return the old value, triggering the reload.

Now: Tab B's localStorage.getItem() immediately returns the new value written by Tab A, so currentUserSub === previousUserSub and the reload never happens. This causes a "mixed user" state with data from both users.

Question: Did Chrome/Firefox recently change how localStorage reads synchronize across tabs? I understand this behavior may be more spec-compliant, but I'm looking for documentation about when this changed.


Solution

  • Question: Did Chrome/Firefox recently change how localStorage reads synchronize across tabs? I understand this behavior may be more spec-compliant, but I'm looking for documentation about when this changed.

    No, localStorage has always worked this way in every browser.

    Maybe:

    but that’s all speculation, and the answer to what you’ve highlighted as being question remains the same. Chrome and Firefox definitely didn’t both deploy the same web-compatibility-breaking change to localStorage in November 2025.