This package helps handle localstorage data. get, set, delete item from local storage. It can even check if a key in localstorage.
Add React-localStorage-handler to your project by executing
$ npm install react-localstorage-handler
or
$ yarn add react-localstorage-handler
and that's it, you're good to go!
//import the checkStorage into your project
import { checkStorage } from 'react-localstorage-handler';
//and then use like so
const status = checkStorage('token');
return status; //will return true is value exsist and false if it doesn't
//import the checkStorage into your project
import { addStorage } from 'react-localstorage-handler';
//and then use like so
addStorage('token', '$39876756453');
//import the checkStorage into your project
import { getStorage } from 'react-localstorage-handler';
//and then use like so
getStorage('token');
//import the checkStorage into your project
import { removeStorage } from 'react-localstorage-handler';
//and then use like so
removeStorage('token');
//import the checkStorage into your project
import { clearStorage } from 'react-localstorage-handler';
//and then use like so
clearStorage();
Name | Use |
---|---|
checkStorage | check is a key is saved in local storage |
addStorage | Add key and value to LocalStorage |
getStorage | Retrieve a value by the key from LocalStorage |
removeStorage | Remove an item by key from LocalStorage |
clearStorage | Clear all LocalStorage for that domain |
Feel free to contribute, just send a pull request ;)
This project is licensed under MIT license.