Skip to main content

useSessionStorage

Callable

  • useSessionStorage<T>(key: string, initialValue: ExcludeFunction<T>, options?: any): readonly [unknown, { resetStorage: () => void; setStorage: (value: unknown) => void }]

  • Returns a hook that provides a sessionStorage value for a given key.


    Type parameters

    • T

    Parameters

    • key: string

      The key to use for the sessionStorage.

    • initialValue: ExcludeFunction<T>

      The initial value to use for the sessionStorage.

    • optionaloptions: any

      Optional options to configure the behavior of the hook.

    Returns readonly [unknown, { resetStorage: () => void; setStorage: (value: unknown) => void }]