https://github.com/solidstategroup/react-native-secured-storage
React Native Secured Storage - Stores encrypted data to AsyncStorage
https://github.com/solidstategroup/react-native-secured-storage
Last synced: 6 months ago
JSON representation
React Native Secured Storage - Stores encrypted data to AsyncStorage
- Host: GitHub
- URL: https://github.com/solidstategroup/react-native-secured-storage
- Owner: SolidStateGroup
- Created: 2020-02-20T11:18:30.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-04T03:24:26.000Z (over 5 years ago)
- Last Synced: 2025-02-28T15:15:19.812Z (12 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 6
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React Native Secured Storage
## Getting Started
### Install
```
yarn add react-native-secured-storage react-native-keychain https://github.com/SolidStateGroup/react-native-pbkdf2 @react-native-community/async-storage
```
or
```
npm install --save react-native-secured-storage react-native-keychain https://github.com/SolidStateGroup/react-native-pbkdf2 @react-native-community/async-storage
```
### Link
- **React Native 0.60+**
[CLI autolink feature](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md) links the module while building the app.
- **React Native <= 0.59**
```bash
$ react-native link react-native-keychain react-native-pbkdf2 @react-native-community/async-storage
```
*Note* For `iOS` using `cocoapods`, run:
```bash
$ cd ios/ && pod install
```
See docs for [manual linking guide](docs/Linking.md)
### **Upgrading to React Native *0.60+***
New React Native comes with `autolinking` feature, which automatically links Native Modules in your project.
In order to get it to work, make sure you `unlink` dependencies first first:
```bash
$ react-native unlink react-native-keychain react-native-pbkdf2 @react-native-community/async-storage
```
## Usage
### Import
```js
import SecuredStorage from 'react-native-secured-storage';
```
### Initialise
```js
await SecuredStorage.init('mypassword');
```
### Unlock storage / Get data
`get()` would be called once on relaunching the app if secured storage has already been initialised.
```js
const storage = await SecuredStorage.get();
const mydata = storage['mydata'];
const mydata2 = SecuredStorage.storage['mydata2'];
```
### Store data
```js
await SecuredStorage.setItem('key', {complex: 'object'});
await SecuredStorage.setItem('key', null, 'or just a string');
```
### Remove data
```js
await SecuredStorage.removeItem('key');
```