Skip to content Skip to sidebar Skip to footer

React Native And Firebase 3

I am trying to integrate React Native and Firebase 3 Authentication. My code. the config But... I'm I missing something? If I am, can you point me in the right direction con

Solution 1:

new firebase don't support react-native. If you want to use firebase in react-native, you use firebase version 2.4.2. In version 3, firebase auth cannot be used but realTimeDatabase can be used in firebase3. If you want to use firebase3 auth, I recommend using web view, react-native-login but I think it's so not good.

Solution 2:

The new release of firebase Javascript SDK 3.1.0 has React Native compatibility.

https://firebase.google.com/support/release-notes/js#3.1.0

Solution 3:

To use the Firebase JS SDK 3.1+, you might have to import the whole package:

import firebase from'firebase'

instead of just firebase/app etc, otherwise you could get this error:

The React native compatibility library was not found.

Solution 4:

Whilst the Firebase JS SDK does work on react native now, it is mainly built for the web and generally not the best solution for react-native.

The Firebase Web SDK runs entirely on react native's JS thread, therefore affecting your application frame rate (the link explains this well).

In my tests, the native firebase SDK's has been roughly 2-3 times quicker than using the web SDK.

But on top of the potential performance impacts there's a lot of features you'll be unable to use with the web SDK on android/ios devices. For example:

  • Notifications / FCM
  • Storage upload/download
  • Firebase Crash Reporting
  • Analytics
  • Use of social authentication providers

The best approach would be to run with the native android/ios firebase sdk's and have a bridge between them and your js code (i.e. a native module setup).

Thankfully you don't have to implement this yourself, there's already modules out there to do this for you:

react-native-firebase for example mirrors the the web sdk's api js side but executes on the native side using the native android & ios firebase sdk's. It's fully compatible with any existing firebase js logic that you may have already implemented and is intended as a drop in replacement for the web sdk.

(disclaimer: I am the author of react-native-firebase)

Post a Comment for "React Native And Firebase 3"