
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
@react-native-async-storage/async-storage
Advanced tools
Asynchronous, persistent, key-value storage system for React Native.
@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.
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();
react-native-mmkv is a fast, small, and easy-to-use key-value storage library for React Native. It is based on Facebook's MMKV storage library and offers better performance compared to AsyncStorage. However, it may not be as widely supported or documented as AsyncStorage.
react-native-sensitive-info is a library for storing sensitive information securely in React Native applications. It uses the device's secure storage mechanisms, such as Keychain on iOS and Keystore on Android, to store data securely. This makes it a better choice for storing sensitive data compared to AsyncStorage, which is not encrypted.
redux-persist is a library that allows you to persist and rehydrate a Redux store. It can be used to store the entire Redux state or specific parts of it in various storage backends, including AsyncStorage. It is useful for applications that use Redux for state management and need to persist state across sessions.
An asynchronous, unencrypted, persistent, key-value storage system for React Native.
Head over to the documentation to learn more.
yarn bundle:android
yarn build:e2e:android
yarn test:e2e:android
yarn bundle:ios
pod install --project-directory=example/ios
yarn build:e2e:ios
yarn test:e2e:ios
Pull requests are welcome. Please open an issue first to discuss what you would like to change.
See the CONTRIBUTING file for more information.
MIT
FAQs
Asynchronous, persistent, key-value storage system for React Native.
The npm package @react-native-async-storage/async-storage receives a total of 1,302,172 weekly downloads. As such, @react-native-async-storage/async-storage popularity was classified as popular.
We found that @react-native-async-storage/async-storage demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.