Skip to content

Localstorage with time to live / expiry, if expiry is zero uses SessionStorage

Notifications You must be signed in to change notification settings

mohamedfasil/browserstorage-ttl

Repository files navigation

browserstorage-ttl

npm version

Localstorage with time to live / expiry, if expiry is zero uses SessionStorage

Usage

npm install browserstorage-ttl

In your file

import Storage from 'browserstorage-ttl';


Storage.set('key', 'value', 30);  // 30 minutes as ttl
const k = Storage.get('key');
console.log(k); // value

Storage.set('anotherkey', 'anothervalue', 0);  // 0 minutes as ttl, will use sessionStorage
const t = Storage.get('anotherkey');

console.log(t); // anothervalue

About

Localstorage with time to live / expiry, if expiry is zero uses SessionStorage

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published