Saving in the browser
Lesson 18 of 20 · Web.Micro
localStorage keeps small data on the device, so the page remembers after a reload.
localStorage.setItem("theme", "dark") saves a string under a key; getItem("theme") reads it back, even after closing the browser. Each site has its own storage.
Check yourself
What type of value does localStorage store?
Do it in the browser: a real HTML, CSS and JavaScript tool, a short mission and instant feedback. No install.
Start this lesson — free