Skip to content

useLocalStorage ​

Hook that manages local storage value

browser
test coverage
Last changed: last month

TIP

This hook uses localStorage browser api to provide enhanced functionality. Make sure to check for compatibility with different browsers when using this api

Installation ​

Library
CLI
Manual
typescript
import { useLocalStorage } from '@siberiacancode/reactuse';

Usage ​

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

Demo ​

Api ​

Parameters

NameTypeDefaultNote
keystring-The key of the storage
initialValue?UseStorageInitialValue<Value>-The initial value of the storage
options?UseStorageOptions<Value>-The options of the storage

Type declaration ​

typescript
import type { UseStorageInitialValue, UseStorageOptions } from '../useStorage/useStorage';

Source ​

Source • Demo

Contributors ​

D
debabin
debabin
H
hywax
hywax

Released under the MIT License.