How I got Expo and react-native-firebase working in one project?

Update 07/2021: This article has become outdated and the solution described . I’ve written a new article describing a lot better approach to this problem. You can find it here. 🔥

//firebaseProvider.tsconsole.log('Using Native Firestore Provider');import firestoreNative from '@react-native-firebase/firestore';

export default firestoreNative;

Update: Note that since Expo SDK 41 the extension .expo.ts is no longer working. More details here.

//firebaseProvider.expo.tsconsole.log('Expo - Using Node.js Firestore provider');
import * as firebase from 'firebase'; import 'firebase/firestore';
const firebaseConfig = {
"apiKey": "===<<<YOUR_API_KEY>>>===",
"authDomain": "===<<<PROJECT_ID>>>",
"projectId": "===<<<PROJECT_ID>>>==="
const db = firebase.firestore();
export default () => db;
import firestore from './firebaseProvider';//example usage
const items = await firestore().collection('items').get();
import analytics from '@react-native-firebase/analytics';//don't track screens for Expo Client - Firebase Web SDK 
//doesn't support it
if (appConstants.appOwnership !== AppOwnership.Expo)
analytics().setCurrentScreen(routeName, routeName);
expo init <<your project name>>
---- then select Bare Workflow (with TypeScript if you prefer) ---
cd <<your project name>>
yarn add @react-native-firebase/app @react-native-firebase/firestore @react-native-firebase/auth firebase
---- For mac/iOS only ----
cd ios && pod install && cd ..



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store