19

I am trying to use to use Firebase (Cloud Firestore) for a react-native app, to store my JSON objects.

I ve seen people using Firebase in their apps (npm install firebase), and others using react-native-firebase.

Most blogs say that Firebase itself is meant for web, so their react-native support is none/less. While a few other blogs and firebase official blog say that Firebase supports react-native.

I am not sure which library to choose, for my react-native project, and what's the difference between them.

Dmytro Rostopira
  • 10,588
  • 4
  • 64
  • 86
kernelman
  • 992
  • 1
  • 13
  • 28

3 Answers3

14

According to project description on GitHub:

React Native Firebase is a light-weight javascript layer connecting you to the native Firebase SDKs for both iOS and Android which aimes to mirror the offical Firebase Web SDK as closely as possible.

Although the official Firebase JS SDK will work with React Native; it is mainly built for the web and has a limited feature-set compared to native.

So, you should choose it, for react native platform. This will allow you to use more features and also benefit from using native sdk's (speed, memory consumption, etc.)

Dmytro Rostopira
  • 10,588
  • 4
  • 64
  • 86
  • Thank you for the reply. It helped. Although, talking about "limited feature-set", my requirement includes a simple editing of an array in a JSON object, which Firebase JS SDK supports (https://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array), but i couldn't find such method on react-native-firebase. I wonder if it is really mirroring !!! – kernelman Oct 01 '18 at 12:25
  • @kernelman firebase actually doesn't work with arrays (at least not, as you would expect it to work), check docs – Dmytro Rostopira Oct 01 '18 at 12:47
  • 1
    @kernelman The `arrayUnion` and `arrayRemove` operations are quite new additions to Cloud Firestore. There is an issue to track adding them to react-native-firebase: https://github.com/invertase/react-native-firebase/issues/1389. The [release notes](https://rnfirebase.io/docs/v5.x.x/release-notes) show that `arrayContains` has been added to 5.0.0, with `arrayUnion` and `arrayRemove` support "coming" soon. – Frank van Puffelen Oct 01 '18 at 14:35
4

Add up from Dima Rostopira's Answer.

You need to use JS SDK in react native when you use expo. Because expo not let you add custom native modules. Else go with react native SDK

kitta
  • 1,723
  • 3
  • 23
  • 33
3

According to doc https://docs.expo.dev/guides/using-firebase/#usage-with-expo

if use expo, you still can use react-native-firebase instead of the https://github.com/firebase/firebase-js-sdk, but need plugin

Aron
  • 169
  • 8
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 03 '22 at 14:39
  • More detail to answer will help people in understanding the difference better. – Sapna Feb 09 '22 at 08:52