Skip to content

An asynchronous, persistent, key-value storage system for React Native.

License

Notifications You must be signed in to change notification settings

alancwoo/react-native-async-storage

 
 

Repository files navigation

React Native Async Storage

An asynchronous, unencrypted, persistent, key-value storage system for React Native.

Getting Started

# Install
$ yarn add @react-native-community/async-storage

# Link
$ react-native link @react-native-community/async-storage

See docs for manual linking guide.

Note: For iOS project using pods, run: $ cd ios/ && pod install

Usage

Import

import AsyncStorage from '@react-native-community/async-storage';

Store data

storeData = async () => {
  try {
    await AsyncStorage.setItem('@storage_Key', 'stored value')
  } catch (e) {
    // saving error
  }
}

Read data

getData = async () => {
  try {
    const value = await AsyncStorage.getItem('@storage_Key')
    if(value !== null) {
      // value previously stored
    }
  } catch(e) {
    // error reading value
  }
}

Advanced

See docs for api and more examples or advanced usages.

Writing tests

Using Jest for testing? Make sure to check out docs on how to integrate it with this module.

Contribution

See the CONTRIBUTING file for how to help out.

License

MIT

About

An asynchronous, persistent, key-value storage system for React Native.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 37.3%
  • Objective-C 32.0%
  • Java 25.8%
  • Shell 2.5%
  • Python 1.9%
  • Ruby 0.5%