Storage

Created: 2018-01-15

Storage Options

When evaluating storage options for React Native, you will want to consider a few things first:

So you’ve answered those questions (and possibly a few more) and are now looking for the right modules to fill your needs. I’ve done quite a bit of reading and these are the best summaries I’ve seen of existing solutions:

You’ll read through those and see that it’s not very comprehensive. In fact, many of those questions are let unanswered. However, you’ll find places to start digging and will have to evaluate everything to see what fits best. The choices are many which is great; you’ll eventually find the perfect fit. But this is also one of the downsides to the React Native ecosystem: The Paradox of Choice

Taking the time to familiarize yourself with the abundance of choices out there will suck up a lot of time that soloprenuers simply don’t have to spare (ultimately, this is what killed my own 1 year venture into the startup world). So to help with that, I’ll be trying my best to keep this wiki page up to date with the available options for each overarching category of modules you may need when developing a mobile app in React Native. I’ll add more in-depth pages for any modules I use in a project, but for others, the best I can promise is to source the bits of information I run into. First up, Storage.

Options

Component State

Redux

Async Storage

Considerations

SQLite

react-native-sqlite-storage

This is the current most recommended module.

Considerations

Troubleshooting

Sharing storage connection between components? https://stackoverflow.com/questions/37342528/reactnative-best-approach-to-share-a-sqlite-instance-across-all-components-and

react-native-sqlite-2
react-native-sqlite

Firebase

Realm

iCloud

Couchbase

MongoDB

GraphQL

redux-persist

Key Features

Considerations

redux-persist-filesystem-storage

Key Features

redux-persist-sensitive-storage

This is a plugin for redux-persist that lets you use react-native-sensitive-info for storage.

redux-persist-transform-encrypt

This is a plugin for redux-persist that automatically encrypts the data in your redux store that is being persisted using the given secret key (from the code).

Note: This is good but not perfect. A better solution would be to use a secret key from KeyChain (iOS) / KeyStore (Android), so it’s not stored in the JS bundle on device. An implementation is being worked on but it’s not released yet.

redux-offline

This uses redux-persist for it’s storage so everything that applies to that, applies here.

react-native-keychain

Key Features

react-native-sensitive-info

Key Features

Considerations

react-native-shared-preferences

https://github.com/sriraman/react-native-shared-preferences

Fork for: https://github.com/rt2zz/redux-persist/issues/185#issuecomment-277128378 https://github.com/nhayfield/react-native-shared-preferences

react-native-fetch-blob

Key Features

react-native-fs

react-native-get-shared-prefs

This has been replaced by react-native-sensitive-info.

react-native-redux-secure-storage

Unreleased project that should be an improvement on redux-persist-transform-encrypt.

redux-persist-transform-encrypt

rxdb

Expo

Native linking is required more many of the different storage options, but Expo does not allow that. So instead, many storage options are built-in. These are some of the options available.

SecureStore

Debugging Tips

Example Use Cases

redux-persist + redux-persist-sensitive-storage + react-native-sensitive-info (keystore) + react-native-sqlite-storage + SQLCipher fork

The why for each module:


Copyright © 2011-2020 Ho Yin Cheng