Skip to content

useStorage ​

Category
Utilities

Hook that manages storage value

typescript
import { useStorage } from '@siberiacancode/reactuse';

Usage ​

typescript
const { value, set, remove } = useStorage('key', 'value');

Demo ​

Api ​

Parameters

NameTypeDefaultNote
keystring-The key of the storage
params.serializer?(value: Value) => string-The serializer function
params.deserializer?(value: string) => Value-The deserializer function
params.storage?Storage-The storage
params.initialValue?UseStorageInitialValue<Value>-The initial value of the storage

Contributors ​

Source • Demo