Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@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 documentation to learn more.
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 820,196 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 1 open source maintainer 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.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.