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

@react-native-async-storage/async-storage

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native-async-storage/async-storage

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

  • 1.17.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

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

@react-native-async-storage/async-storage is a simple, unencrypted, asynchronous, persistent, key-value storage system for React Native applications. It is designed to store small amounts of data, such as user preferences, settings, and other state information.

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

Store Data

This feature allows you to store data in the form of key-value pairs. The code sample demonstrates how to store a string value with a specific key.

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

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

storeData('username', 'JohnDoe');

Retrieve Data

This feature allows you to retrieve data stored in AsyncStorage using a key. The code sample demonstrates how to get a stored value and handle it.

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

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

getData('username').then(value => console.log(value));

Remove Data

This feature allows you to remove data from AsyncStorage using a key. The code sample demonstrates how to delete a stored value.

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

const removeData = async (key) => {
  try {
    await AsyncStorage.removeItem(key);
  } catch(e) {
    // remove error
  }
};

removeData('username');

Clear All Data

This feature allows you to clear all data stored in AsyncStorage. The code sample demonstrates how to clear all stored values.

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

const clearAll = async () => {
  try {
    await AsyncStorage.clear();
  } catch(e) {
    // clear error
  }
};

clearAll();

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

Keywords

FAQs

Package last updated on 18 Mar 2022

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