Content
useLocalStorage
A hook that manages a state variable in sync with local storage, allowing data persistence across browser sessions.
useLocalStorage
Usage
API
useLocalStorage
Parameters
Name | Type | Description |
---|---|---|
key | string | The key for the local storage item. |
initialValue | T | The initial value for the state variable. |
Returns
Name | Type | Description |
---|---|---|
storedValue | T | The current value synchronized with local storage. |
setValue | (value: T) => void | A function to update the state and sync it with local storage. |