@analytics/session-storage-utils — Tiny SessionStorage utility library. One of the small, focused utility packages that power the analytics library, usable standalone.
Full documentation, synced from the package README:
A tiny sessionStorage utility library with fallbacks in 234 bytes.
This module will automatically fail back to global window storage if sessionStorage is not available.
Exposes hasSessionStorage, getSessionItem, setSessionItem, & removeSessionItem functions.
Install @analytics/session-storage-utils from npm.
npm install @analytics/session-storage-utilsBelow is the api for @analytics/session-storage-utils. These utilities are tree-shakable.
hasSessionStorageCheck if sessionStorage is supported
import { hasSessionStorage } from '@analytics/session-storage-utils'
if (hasSessionStorage()) {
// Use session storage
}getSessionItemGet a sessionStorage value.
import { getSessionItem } from '@analytics/session-storage-utils'
const value = getSessionItem('item-key')setSessionItemSet a sessionStorage value.
import { setSessionItem } from '@analytics/session-storage-utils'
setSessionItem('item-key', 'a')removeSessionItemDelete a sessionStorage value.
import { removeSessionItem } from '@analytics/session-storage-utils'
removeSessionItem('item-key')