0
Challenge · 58Routing & Data

Session Storage

Coreused in ~40% of apps

Sometimes you want data to vanish when the user closes the tab — a multi-step checkout, a one-off draft, a 'just for this visit' flag. That is sessionStorage.

Core idea. sessionStorage is the exact same API as localStorage, but its data is scoped to a single tab and is erased when that tab closes — perfect for per-session, throwaway state.
Playground, this isn't a screenshot
FOCUSED TAB

Writes run as Tab A. Watch where each value lands.

localStorage — shared by every tab on this origin
color: null
Tab A
sessionStorage (private)
color: null
localStorage (shared view)
color: null
Tab B
sessionStorage (private)
color: null
localStorage (shared view)
color: null

Save to localStorage and both tabs show it — one shared box per origin. Save to sessionStorage and only the focused tab keeps it; close that tab and the value is gone, while localStorage survives.

↑ play a little first, then dig in