useSessionStorage

Custom hook that uses the sessionStorage API to persist state across page reloads.

Usage

import { useSessionStorage } from "@teasim/hooks";
export default function Component() {
const [value, setValue, removeValue] = useSessionStorage("test-key", 0);
return (
<div>
<p>Count: {value}</p>
<button onClick={() => { setValue((x) => x + 1); }} >
Increment
</button>
<button onClick={() => { setValue((x) => x - 1); }} >
Decrement
</button>
<button onClick={() => { removeValue(); }} >
Reset
</button>
</div>
);
}