Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/just1and0/react-localstorage-handler
πβοΈThis package helps handle localstorage data. get, set, delete item from local storage. It can even check if a key in localstorage
https://github.com/just1and0/react-localstorage-handler
localstorage reactjs web
Last synced: about 1 month ago
JSON representation
πβοΈThis package helps handle localstorage data. get, set, delete item from local storage. It can even check if a key in localstorage
- Host: GitHub
- URL: https://github.com/just1and0/react-localstorage-handler
- Owner: just1and0
- License: mit
- Created: 2019-04-05T16:50:12.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-24T21:49:24.000Z (over 5 years ago)
- Last Synced: 2024-12-08T05:10:03.540Z (2 months ago)
- Topics: localstorage, reactjs, web
- Language: JavaScript
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# react-localstorage-handler
[![Build Status](https://travis-ci.com/just1and0/React-localStorage-handler.svg?branch=master)](https://travis-ci.com/just1and0/React-localStorage-handler)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/just1and0/React-localStorage-handler/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/just1and0/React-localStorage-handler/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/just1and0/React-localStorage-handler/badges/build.png?b=master)](https://scrutinizer-ci.com/g/just1and0/React-localStorage-handler/build-status/master)
This package helps handle localstorage data. get, set, delete item from local storage. It can even check if a key in localstorage.
### Installation
Add React-localStorage-handler to your project by executing
```sh
$ npm install react-localstorage-handler
or
$ yarn add react-localstorage-handler
```
> and that's it, you're good to go!
## Usage
##### To check if a key exists use the *checkStorage()*
```sh
//import the checkStorage into your projectimport { 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
```
#
##### To Add key and value to LocalStorage *addStorage()*
```sh
//import the checkStorage into your projectimport { addStorage } from 'react-localstorage-handler';
//and then use like so
addStorage('token', '$39876756453');
```
###### To Retrieve a value by the key from LocalStorage *getStorage()*
```sh
//import the checkStorage into your projectimport { getStorage } from 'react-localstorage-handler';
//and then use like so
getStorage('token');
```
###### To Remove an item by key from LocalStorage *removeStorage()*
```sh
//import the checkStorage into your projectimport { removeStorage } from 'react-localstorage-handler';
//and then use like so
removeStorage('token');
```
###### To Clear all LocalStorage *clearStorage()*
```sh
//import the checkStorage into your projectimport { clearStorage } from 'react-localstorage-handler';
//and then use like so
clearStorage();
```
## Props
#### all React-localStorage-handler
|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 |
## Contributing
Feel free to contribute, just send a pull request ;)
## Licensing
This project is licensed under MIT license.