0Pricing
JavaScript Academy · Lesson

Storage Events and Limits

React to changes and respect quota limits.

Reacting to Storage Changes

The storage event lets one tab react when another tab changes localStorage. It enables simple cross-tab synchronization.

Listening for storage

Add a listener on window. It fires in OTHER tabs of the same origin whenever localStorage changes, not in the tab that made the change.

window.addEventListener("storage", (e) => {
  console.log("Key changed:", e.key);
});

All lessons in this course

  1. Storing and Reading Data
  2. localStorage vs sessionStorage
  3. Storing Objects with JSON
  4. Storage Events and Limits
← Back to JavaScript Academy