# react-native-key-value-store

> A wrapper for React-Native AsyncStorage

Latest version **1.0.1** (published 2016-09-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-key-value-store
pnpm add react-native-key-value-store
yarn add react-native-key-value-store
bun add react-native-key-value-store
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-09-21 |
| First published | 2016-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Carl Craig |
| Maintainers | carlcraig |
| Keywords | React Native, AsyncStorage, data, store, key value, iOS, Android |

## Links

- npm: https://www.npmjs.com/package/react-native-key-value-store
- Repository: https://github.com/carlcraig/react-native-key-value-store
- Homepage: https://github.com/carlcraig/react-native-key-value-store/
- Issues: https://github.com/carlcraig/react-native-key-value-store/issues
- npm.io page: https://npm.io/package/react-native-key-value-store

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-09-21
- 1.0.0 — 2016-09-18

## README

react-native-key-value-store
==============================

> A wrapper for React-Native AsyncStorage

Installation
------------

```
npm i --save react-native-key-value-store
```

Basic Usage
-----------

All methods on the `KeyValueStore` are `async` and therefore return `promises`.

```js
import Storage from 'react-native-key-value-store';

let value = await Storage.get('foo', 'default value');
console.log(value); // should be default value if foo hasn't already been set

await Storage.set('foo', 'bar');

value = await Storage.get('foo');
console.log(value); // should be 'bar' as it has been set
```

Methods
-------

### `get(key, defaultValue)`

This will get a value based on the key provided. You can also set a default value
in case the key does not exist in the store.

### `set(key, value)`

This will set a value based for the key provided.

### `remove(key)`

This will delete the key from the store.

### `keys()`

This will return an array of all keys in the store.

Creating Namespaced Stores
--------------------------

The default key value store has a namespace of `@Default`

You can create your own key value stores with different namespaces

```js
import { KeyValueStore } from 'react-native-key-value-store';

const appStore = new KeyValueStore('@App');
```

This will allow you to isolate different key/values, and will also affect the
return value from `keys()` method, as it will check the namespace.

License
-------

react-native-key-value-store is licensed with the MIT license.

See LICENSE for more details.

---
_Source: https://npm.io/package/react-native-key-value-store · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
