useLocalStorage
localStorage API](https://developer.Installation
npx sse-tool add use-local-storage
npm install sse-hooks
Usage
import { useLocalStorage } from "./{hooks file}";
const [count, setCount, removeCount] = useLocalStorage("count", 0);
// Access the `count` value, the `setCount` function to update it and `removeCount` function to remove the key from storage.
import { useLocalStorage } from "sse-hooks";
const [count, setCount, removeCount] = useLocalStorage("count", 0);
// Access the `count` value, the `setCount` function to update it and `removeCount` function to remove the key from storage.
API
Parameters
| Name | Type | Description |
| :----------- | :----------------------- | :------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------- |
| key | string | The key under which the value will be stored in local storage. |
| initialValue | T | Function | The initial value of the state or a function that returns the initial value. |
| options | UseLocalStorageOptions | Options for customizing the behavior of serialization and deserialization (optional). |
Return Value
Returns any.
A tuple containing the stored value, a function to set the value and a function to remove the key from storage.