import { Dispatch, SetStateAction } from 'react'; export type PersistentStateStorage = 'localStorage' | 'sessionStorage' | 'cookie'; /** * 'effect' (default): the stored value is read in a useEffect after mount, * so `value` starts as `initialValue` on every render — including the * first client render of a component that was server-rendered — and only * updates once the effect runs. This is what makes it hydration-safe. * * 'sync': the stored value is read synchronously during the initial * render, so there's no post-mount update and no flash of `initialValue`. * Only use this for components that are never part of an SSR/hydration * pass (e.g. mounted purely client-side, behind a data-loading gate) — * otherwise the server and the first client render will disagree and * React will emit a hydration mismatch and force a visible patch-up, * which is the exact flash this mode is meant to avoid. */ export type PersistentStateHydration = 'effect' | 'sync'; export interface UsePersistentStateOptions { initialValue: T; storageKey?: string; isControlled?: boolean; validate?: (value: unknown) => value is T; storage?: PersistentStateStorage; hydration?: PersistentStateHydration; /** Only used when storage is 'cookie'. Defaults to one year. */ maxAgeSeconds?: number; } export interface UsePersistentStateResult { value: T; setValue: Dispatch>; hydrated: boolean; } export declare function usePersistentState({ initialValue, storageKey, isControlled, validate, storage, hydration, maxAgeSeconds, }: UsePersistentStateOptions): UsePersistentStateResult;