You own several React Native applications designed for iOS and Android platforms, and you intend to enable them to exchange data through a centralized storage system on the user's device. A practical scenario involves a collection of RPG games within your app portfolio that share a common gold currency. For instance, if a user achieves great success in one RPG (e.g., app #1) and accumulates a substantial amount of gold, they should retain access to this wealth when transitioning to another RPG within the series. This interconnected data sharing mechanism ensures a seamless and immersive experience for the user as they progress through your game collection. Isn't that a fascinating concept to enhance user engagement and convenience across your app ecosystem?
Install npm
npm install @software-lab/react-native-shared-storage
Install yarn
yarn add @software-lab/react-native-shared-storage
The simplest way to use this library is in the default mode, where it stores the reducer data directly in the shared storage.
There's a limit to the amount of data that can stored this way, so it's recommended to only use this with very minimal reducers, e.g. one that just stores key data you need to share.
import { createSharedStorage } from 'react-native-shared-storage';
// Use your reducer
import sharedDataReducer from './data/slice';
// SharedStorage expects a reverse group name qualifier
const sharedStorage = createSharedStorage('group.myapp');
const persistConfig = {
key: 'root',
storage: sharedStorage,
};
const mainReducer = combineReducers({
sharedData: persistReducer(persistConfig, sharedDataReducer),
});
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library