React Native Architecture

Since React Native apps are built using JavaScript we use the same design principles as in Front-end Architecture.

Storage

React Native provides AsyncStorage for data persistence. AsyncStorage is a simple, unencrypted, asynchronous, key-value storage. On iOS, AsyncStorage stores small values in a serialized dictionary and larger values in separate files. On Android, AsyncStorage uses RocksDB or SQLite based on what is available. The advantage of using AsyncStorage is that it is provided out of the box with React Native and requires no additional setup in order to use it. The disadvantage of AsyncStorage is that it is relatively slow and has no indexing capabilities, therefore, it is not the best option when working with large amounts of data. We use AsyncStorage only for very basic cases and whenever a more complex logic is required we prefer using Realm.

Realm

When the application needs to operate with large amounts of data Realm is our tool of choice for data layer as it is usually faster than SQLite or AsyncStorage. Realm is a database for mobile applications which provides easy object persistence and full query capabilities. Realm is a statically typed database, therefore, you need to define the schema of the database before it can be used. In addition, for easy integration with React Native, Realm provides some React Native specific components such as ListView.

Redux-persist

When the application doesn’t operate with large amounts of data and doesn’t need querying capabilities redux-persist is a good option since it can be backed by AsyncStorage. Redux-persist supports AsyncStorage as its storage engine and allows Redux stores to be persisted and rehydrated seamlessly.