Installation
npx sse-hooks add use-session-storage
yarn dlx sse-hooks add use-session-storage
pnpm dlx sse-hooks add use-session-storage
deno run -A npm:sse-hooks add use-session-storage
bunx sse-hooks add use-session-storage
Usage
example.ts
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.
API
Parameters
| Prop | Default | Type |
|---|---|---|
options |
|
Options for customizing the behavior of serialization and deserialization (optional).
|
key | - |
The key under which the value will be stored in session storage. |
initialValue | - |
The initial value of the state or a function that returns the initial value. |
Returns
| Return Value | Default | Type |
|---|---|---|
[0] | - |
|
[1] | - |
|
[2] | - |
|
Types Aliases
No specific type aliases defined for this component.