Skip to content

useSessionStorage ​

browser
test coverage
Last changed: 10 days ago

TIP

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

Hook that manages session storage value

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

Usage ​

typescript
const { value, set, remove } = useSessionStorage('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

Source ​

Source • Demo

Contributors ​

Avatardebabin
Avatarhywax

Released under the MIT License.