useSessionStorage
sessionStorage API](https://developer.Installation
npx sse-tool add use-session-storage
npm install sse-hooks
Usage
import { useSessionStorage } from "./{hooks file}";
const [count, setCount, removeCount] = useSessionStorage("count", 0);
// Access the `count` value, the `setCount` function to update it and `removeCount` function to remove the key from storage.
import { useSessionStorage } from "sse-hooks";
const [count, setCount, removeCount] = useSessionStorage("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 session storage. |
| initialValue | T | Function | The initial value of the state or a function that returns the initial value. |
| options | UseSessionStorageOptions | 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.