import * as React from 'react'; /** * The options for the `useLocalStorage` hook. */ export interface UseLocalStorageOptions { /** * The key to use in localStorage. */ key: string; /** * The initial value to use when no value is found in localStorage. */ initialValue: T; /** * Custom serializer function. Defaults to `JSON.stringify`. */ serializer?: (value: T) => string; /** * Custom deserializer function. Defaults to `JSON.parse`. */ deserializer?: (value: string) => T; } /** * The return type of the `useLocalStorage` hook. * A tuple containing: * 1. The current stored value. * 2. A setter function to update the value. * 3. A function to remove the value from localStorage. */ export type UseLocalStorageReturnType = [T, React.Dispatch>, () => void]; /** * A custom hook that syncs state with localStorage. * Uses initialValue for SSR and first client render to avoid hydration mismatch, * then reads the stored value in useLayoutEffect (before paint) so no flash occurs. * * @param {UseLocalStorageOptions} options - The options for the local storage hook. * @returns A tuple containing the current value, a setter function, and a remove function. * * @example * ```tsx * const MyComponent = () => { * const [sizes, setSizes, removeSizes] = useLocalStorage({ * key: 'splitter-sizes', * initialValue: [50, 50] * }); * * return ( * setSizes(e.sizes)}> * * * * ); * }; * ``` */ export declare function useLocalStorage({ key, initialValue, serializer, deserializer }: UseLocalStorageOptions): UseLocalStorageReturnType;