/**
* Synchronizes state with localStorage, providing persistent storage across sessions.
* Automatically serializes/deserializes JSON values.
*
* @template T - The type of the stored value
* @param key - The localStorage key
* @param initialValue - The initial value if no stored value exists
* @returns A tuple containing [storedValue, setValue, removeValue]
*
* @example
* ```tsx
* function ThemeSelector() {
* const [theme, setTheme, resetTheme] = useLocalStorage('theme', 'light');
*
* return (
*