useReadLocalStorage
Read a localStorage key reactively without creating a setter.
Read a localStorage key reactively without creating a setter.
Usage
import { useReadLocalStorage } from "@tilt-legal/cubitt-components/utilities/hooks";
const theme = useReadLocalStorage<string>("theme");API
Signature
declare function useReadLocalStorage<T>(key: string, options: Options<T, false>): T | null | undefined;
declare function useReadLocalStorage<T>(key: string, options?: Partial<Options<T, true>>): T | null;Parameters
This hook takes no arguments.
Return Value
| Value | Type | Description |
|---|---|---|
return | `T | null |
useLocalStorage
Custom hook that uses the [`localStorage API`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) to persist state across page reloads.
useSessionStorage
Custom hook that uses the [`sessionStorage API`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) to persist state across page reloads.