mazey
    Preparing search index...

    Function getSessionStorage

    • Read a value from sessionStorage, parsing JSON when possible.

      Usage:

      import { setSessionStorage, getSessionStorage, setLocalStorage, getLocalStorage } from "mazey";

      setSessionStorage("test", "123");
      const ret1 = getSessionStorage("test");
      setLocalStorage("test", "123");
      const ret2 = getLocalStorage("test");
      console.log(ret1, ret2);

      // Wrap the helpers with a project-specific key prefix.
      const projectName = "mazey";
      function mSetLocalStorage (key, value) {
      return setLocalStorage(`${projectName}_${key}`, value);
      }

      function mGetLocalStorage (key) {
      return getLocalStorage(`${projectName}_${key}`);
      }

      Output:

      123 123
      

      Type Parameters

      • T

      Parameters

      • key: string

        Storage key.

      Returns T | null

      The parsed value, raw stored value, or null when no value exists.