Skip to content

Fast, accurate OCR with correctness assessment.

404 B
Raw Blame
import { useLocalStorageState } from 'ahooks';

/**
 * Typed localStorage state with JSON serialization.
 * Wrapper around ahooks useLocalStorageState with project prefix.
 *
 * @example
 * const [value, setValue] = useStorage<string>('sidebar-width', '240px');
 */
export function useStorage<T>(key: string, defaultValue?: T) {
  return useLocalStorageState<T>(`ude:${key}`, {
    defaultValue,
  });
}