import { useEffect, useState } from "react";
export function useLocalStorage(key, initial) {
const [value, setValue] = useState(() => {
try {
const raw = window.localStorage.getItem(key);
return raw ? JSON.parse(raw) : initial;
} catch {+8 more lines…
Updated Jul 17, 2026