API Web Storage
LocalStorage stores strings for a particular origin. Use it for small non-sensitive preferences and handle storage failures.
Where to run this
Use a local browser project for this example. It needs browser permissions, additional files, a server endpoint, or a library as described below. The restricted playground cannot provide those dependencies.
A practical example
try {
localStorage.setItem("club-view", "list");
console.log(localStorage.getItem("club-view"));
} catch (error) {
console.log("Storage unavailable");
}
What happens
A normal permitted page stores and reads list.