async-storage

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

  • 所有者: react-native-async-storage/async-storage
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

React Native Async Storage

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

AsyncStorage v2 is out!

Release Candidate for AsyncStorage v2 is out. More info can be found here..

Getting Started

Install

$ yarn add @react-native-community/async-storage
  • React Native 0.60+

CLI autolink feature links the module while building the app.

  • React Native <= 0.59
$ react-native link @react-native-community/async-storage

Note For iOS using cocoapods, run:

$ cd ios/ && pod install

See docs for manual linking guide

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 Async Storage first:

$ react-native unlink @react-native-community/async-storage

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

主要指標

概覽
名稱與所有者react-native-async-storage/async-storage
主編程語言TypeScript
編程語言Java (語言數: 12)
平台
許可證MIT License
所有者活动
創建於2019-02-06 15:51:20
推送於2025-06-12 07:58:08
最后一次提交
發布數117
最新版本名稱@react-native-async-storage/async-storage@2.2.0 (發布於 2025-06-05 12:15:49)
第一版名稱v1.0.0 (發布於 2019-02-11 17:35:53)
用户参与
星數4.9k
關注者數34
派生數477
提交數550
已啟用問題?
問題數675
打開的問題數18
拉請求數393
打開的拉請求數1
關閉的拉請求數69
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?