RxFire is an open-source JavaScript library that provides RxJS observable bindings for various Firebase web client SDKs, including Firestore, Realtime Database, Cloud Storage, Authentication, and Functions. Currently at version 6.1.0, it targets Firebase JS SDK v9+ modular APIs and is compatible with RxJS v6 and v7. The library offers observable creators that simplify asynchronous data streams from Firebase, making it portable across frameworks and tree-shakeable. Key differentiators include the ability to easily combine multiple Firebase data sources using RxJS operators and simplify code-splitting of Firebase features, acting as a complementary tool rather than a full wrapper for the Firebase SDK. It is under active maintenance by the Firebase Extended team.
npm install rxfireVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize Firebase, obtain a Firestore instance, create a collection query, and subscribe to real-time data changes using RxFire's `collectionData` function. It includes an example of logging data updates.
Update all Firebase SDK imports and calls to the modular style (e.g., `getFirestore(app)` instead of `firebase.firestore()`). Ensure your `rxjs` installation is compatible with `^6.0.0 || ^7.0.0` as specified in RxFire's peer dependencies. Review the RxFire v6 migration guide (if available) or the Firebase v9 upgrade guide.
Ensure `firebase` and `rxjs` are explicitly installed in your project using `npm install firebase rxjs` or `yarn add firebase rxjs`. Check the `peerDependencies` field in RxFire's `package.json` for the exact version ranges required.
Always use named imports from specific subpaths for both RxFire and Firebase. For example, `import { initializeApp } from 'firebase/app';` and `import { collectionData } from 'rxfire/firestore';`.While widely used, developers should be aware of its 'Beta' status and monitor the official GitHub repository for announcements regarding potential API changes or breaking updates, especially during major Firebase SDK releases.
Always pass the correct Firebase service instance obtained from the modular SDK functions (e.g., `getFirestore(app)`, `getStorage(app)`, `getAuth(app)`) to the corresponding RxFire observable creators.
Ensure you are using ESM `import` syntax (`import { collectionData } from 'rxfire/firestore';`) and that your project's build setup (e.g., `package.json` `"type": "module"` or bundler configuration) correctly handles ESM.Call `initializeApp()` from `firebase/app` once at the beginning of your application's lifecycle, providing your Firebase project configuration.
Install the `firebase` package using `npm install firebase` or `yarn add firebase`. Verify that the installed `firebase` version (`npm view firebase version`) falls within the peer dependency range specified by RxFire (`^9.0.0 || ^10.0.0 || ^11.0.0`).
Ensure you pass the correct Firebase service instance. For example, pass `getFirestore(app)` to `collectionData`, `getStorage(app)` to `getDownloadURL`, and `getAuth(app)` to authentication-related RxFire functions.