0

Now I am using Firebase authentication in React Native project. I started with 'firebase' module at the beginning of the project. And after that I added 'react-native-firebase' module for some reason.(crashlytics, Deep link etc) Then in one *.js file(e.g: Login.js), can I use those two modules at the same time?

Login method of those two module is different a little each other.

e.g: firebase

import firebaseAuth from '../config';
...  ...
firebaseAuth.signInWithEmailAndPassword(this.state.email, this.state.password)
  .then(() => this.props.navigation.navigate('CreateRoom'))
  .catch(error => this.setState({ errorMessage: error.message }), alert(this.state.errorMessage));

@react-native-firebase/auth

import auth from '@react-native-firebase/auth';
...   ...
    try {
      const doLogin = await auth().signInWithEmailAndPassword(
        this.state.email,
        this.state.password,
      );
      if (doLogin.user) {
        this.props.navigation.navigate('Main');
      } else {
        alert('User info incorrect.')
      }
    } catch (err) {
        console.log('Login Error', err);
    }

Is it possible to use those 2 modules at the same time? And what is the difference of those 2 modules? Any answer will be appreciate. Thank you.

SatelBill
  • 641
  • 2
  • 12
  • 28
  • [What is the difference?](https://stackshare.io/stackups/firebase-vs-react-native-firebase) – 高鵬翔 Jun 23 '20 at 08:35
  • While it may technically be possible to use both the Firebase JavaScript SDK and the `react-native-firebase` library in one app, I highly recommend picking one and sticking with that. If you need features that are only available for native mobile platforms (such as Crashlytics and Dynamic Links) that means you should use `react-native-firebase` as they are not available in the JavaScript SDKs (as they're not available for web apps). – Frank van Puffelen Jun 23 '20 at 13:52
  • Thank you so much Frank van Puffelen. Is there any way to proceed the phone authentication with 'firebase' Javascript SDK? – SatelBill Jun 23 '20 at 15:03
  • Our App works on Web as well as Android and iOS. Currently, the same codebase works because we use the Javascript Web SDK. If we move to react-native-firebase, does it mean 2 separate codebases now - one for web and other for mobile apps? I am assuming here that react-native-firebase won't compile for RNweb. If there a way to have both libraries live inside the same app? – Parag Thakur Mar 19 '23 at 03:28

0 Answers0