@software-lab/react-native-shared-storage
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

@software-lab/react-native-shared-storage

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?

Installation

Install npm

npm install @software-lab/react-native-shared-storage

Install yarn

yarn add @software-lab/react-native-shared-storage

Usage

Shared reducer data on the keychain

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),
});

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Package Sidebar

Install

npm i @software-lab/react-native-shared-storage

Weekly Downloads

9

Version

1.1.3

License

MIT

Unpacked Size

22.8 kB

Total Files

14

Last publish

Collaborators

  • alex98247