Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-native-community/async-storage

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native-community/async-storage

Asynchronous, persistent, key-value storage system for React Native.

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
134K
decreased by-4.51%
Maintainers
1
Weekly downloads
 
Created

What is @react-native-community/async-storage?

@react-native-community/async-storage is an asynchronous, unencrypted, persistent, key-value storage system for React Native. It is designed to store small amounts of data, such as user preferences, app settings, or other lightweight data that needs to persist across app sessions.

What are @react-native-community/async-storage's main functionalities?

Store Data

This feature allows you to store a key-value pair in the storage. The `setItem` method is used to save the data asynchronously.

async function storeData(key, value) {
  try {
    await AsyncStorage.setItem(key, value);
  } catch (e) {
    // saving error
    console.error(e);
  }
}

Retrieve Data

This feature allows you to retrieve a value by its key from the storage. The `getItem` method is used to fetch the data asynchronously.

async function retrieveData(key) {
  try {
    const value = await AsyncStorage.getItem(key);
    if (value !== null) {
      // value previously stored
      return value;
    }
  } catch (e) {
    // error reading value
    console.error(e);
  }
}

Remove Data

This feature allows you to remove a key-value pair from the storage. The `removeItem` method is used to delete the data asynchronously.

async function removeData(key) {
  try {
    await AsyncStorage.removeItem(key);
  } catch (e) {
    // remove error
    console.error(e);
  }
}

Merge Data

This feature allows you to merge an existing value with a new value for a given key. The `mergeItem` method is used to update the data asynchronously.

async function mergeData(key, value) {
  try {
    await AsyncStorage.mergeItem(key, value);
  } catch (e) {
    // merge error
    console.error(e);
  }
}

Clear All Data

This feature allows you to clear all key-value pairs from the storage. The `clear` method is used to remove all data asynchronously.

async function clearAllData() {
  try {
    await AsyncStorage.clear();
  } catch (e) {
    // clear error
    console.error(e);
  }
}

Other packages similar to @react-native-community/async-storage

Keywords

FAQs

Package last updated on 14 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc