How to store value in LocalStorage in React Native

There are several options to do such thing.

For most basic things you can use AsyncStorage from react-native, but there are other options, like Realm and SQLite that are libraries to store data on device.

If you are using Redux, you can also use redux-persist.

EDIT

As @honor said, you should use react-native-community/react-native-async-storage instead of the older AsyncStorage referenced here (deprecated)


For anyone who is still looking for this, RN async storage has been deprecated. You can use this: https://github.com/react-native-community/react-native-async-storage instead.


you can use sync storage that is easier to use than async storage:

import SyncStorage from 'sync-storage';

...

SyncStorage.set('foo', 'bar');

const result = SyncStorage.get('foo');
console.log(result); // 'bar'