/** * Hook that manages state synchronized with sessionStorage. * * Provides persistent state that survives page refreshes but is cleared when * the browser tab is closed. Automatically handles JSON serialization/deserialization * and provides SSR-safe initialization. * * @template T - The type of the stored value * @param key - The sessionStorage key to store the value under * @param initialValue - The default value used when no stored value exists * * @returns A tuple containing: * - The current stored value (or initial value if none exists) * - A setter function that updates both state and sessionStorage * * @example * ```tsx * function UserPreferences() { * const [theme, setTheme] = useSessionStorageState('theme', 'light'); * const [sidebarOpen, setSidebarOpen] = useSessionStorageState('sidebar', true); * * return ( *