ProgramsJavaScript

JavaScript LocalStorage and SessionStorage

Save data in the browser with JavaScript localStorage and sessionStorage. Store objects as JSON, set expiry times, sync tabs and handle storage limits.

10 programs · open one, then the next

Start with LocalStorage Basics
  1. 01LocalStorage BasicsBeginnerLearn localStorage in JavaScript: setItem, getItem, removeItem, clear, keys, storing objects with JSON and checking availability. Explanation and output.Open example →
  2. 02SessionStorage BasicsBeginnerLearn sessionStorage in JavaScript: tab-only storage, page view counts, navigation history, temporary form data and session timeouts. Explanation and output.Open example →
  3. 03Storage Event ListenerIntermediateUse the storage event in JavaScript to react to localStorage changes from other tabs, plus custom events in the same tab. Explanation and output.Open example →
  4. 04Storage JSON HandlingIntermediateStore objects and arrays in localStorage with JSON in JavaScript: stringify, parse, safe defaults, a helper class and expiry times. Explanation and output.Open example →
  5. 05Storage Quota ManagementIntermediateManage browser storage quota in JavaScript: estimate(), localStorage size, QuotaExceededError and cleanup of old data, with explanation and output.Open example →
  6. 06Storage UtilitiesIntermediateBuild storage utility classes in JavaScript: a JSON helper, expiring items, namespaced keys and an XOR encoding demo, with explanation and output.Open example →
  7. 07Storage MigrationAdvancedMigrate stored data in JavaScript: rename keys, track versions, back up first and run step-by-step localStorage migrations. Explanation and output.Open example →
  8. 08Storage Session ManagementIntermediateManage user sessions in JavaScript with sessionStorage and localStorage: create, expire, idle warnings and remember me, with explanation and output.Open example →
  9. 09Storage Custom HooksAdvancedWrite reusable storage hooks in JavaScript like useLocalStorage, with defaults, expiry and cross-tab sync. Includes a fixed setter bug, explanation and output.Open example →
  10. 10Storage Cross-Tab CommunicationAdvancedCommunicate between browser tabs in JavaScript with storage events, BroadcastChannel, shared state and leader election. Simple explanation and real output.Open example →