Read a value from localStorage, parsing JSON when possible.
localStorage
Usage:
import { setLocalJSON, getLocalJSON } from "mazey";setLocalJSON("preferences", { theme: "dark" });const preferences = getLocalJSON("preferences");console.log(JSON.stringify(preferences)); Copy
import { setLocalJSON, getLocalJSON } from "mazey";setLocalJSON("preferences", { theme: "dark" });const preferences = getLocalJSON("preferences");console.log(JSON.stringify(preferences));
Output:
{"theme":"dark"} Copy
{"theme":"dark"}
Storage key.
The parsed value, raw stored value, or null when no value exists.
null
Read a value from
localStorage, parsing JSON when possible.Usage:
Output: