How can we use Firebase Analytics with an expo based react-native app

The default binding that Expo has for Firebase is based on the Firebase JavaScript SDK. This means that it is limited to the Firebase products that are available to web developers, which (since September 2019) includes Google Analytics for Firebase (the new name for Firebase Analytics).

Have a look at the Firebase documentation to learn how to get started with analytics on the web.


Previous, and now outdates, answer below. I'm leaving it here for reference for how.

The default binding that Expo has for Firebase is based on the Firebase JavaScript SDK. This means that it is limited to the Firebase products that are available to web developers, which unfortunately doesn't include Google Analytics for Firebase (the new name for Firebase Analytics).

This means that you'll have to rely on a third party library for binding other Firebase features into your Expo app. And since those libraries are bridging to the native Android and iOS SDKs of Firebase, there is no way to use them without detaching/ejecting.

Also see:

  • this discussion on expo.canny.io where an Expo team member weighed in
  • another discussion on expo.canny.io
  • Invertase's bindings from React Native to Firebase
  • Intertase's blog post on using Cloud Firestore from React Native

Check out a detailed answer of how to integrate Firebase Analytics into Expo here: https://github.com/firebase/firebase-js-sdk/issues/2244#issuecomment-558621111

In short:

You can integrate Firebase Analytics into Android App using android.googleServicesFile field. Works at least for SDKs 33, 34, 35.

For iOS App ios.googleServicesFile field is missing in the Expo Docs but still can be used for Firebase Analytics. Works at least for SDK 34. Issue in Expo repo was created: https://github.com/expo/expo/issues/6379