Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: deprecation guide for moving to firebase-js-sdk v9 modular API #8279

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ description: Welcome to React Native Firebase! To get started, you must first se
next: /typescript
---

> React Native Firebase has begun to deprecate the namespaced API (i.e firebase-js-sdk `< v9` chaining API). React Native Firebase will be moving to the modular API (i.e. firebase-js-sdk `>= v9`) in the next major release. See [migration guide]() for more information.
Copy link
Collaborator

@mikehardy mikehardy Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything looks beautiful except the guide isn't hooked up to the URL here and the prev/next links need rearrange, you probably know that
only commenting to say this all looks like a +1 from me otherwise, even though it's draft at moment


React Native Firebase is the officially recommended collection of packages that brings React Native support for all Firebase services on both Android and iOS apps.

React Native Firebase fully supports React Native apps built using [React Native CLI](https://reactnative.dev/docs/environment-setup?guide=native) or using [Expo](https://docs.expo.dev/).
Expand Down
54 changes: 54 additions & 0 deletions docs/migrating-to-v22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: Migrating to v22
description: Migrate to React Native Firebase v22
next: /typescript
previous: /
---

# Switching off warning logs

You may notice an influx of console warning logs as we continue deprecating all existing namespaced API. If you would like to switch these logs off, you may set the following global property to `true` anywhere before you initialise Firebase.

```js
globalThis.RNFB_SILENCE_V8_DEPRECATION_WARNINGS = true;
```

# Migrating to React Native modular API

React Native Firebase does not currently have documentation for modular API. A refresh of the React Native Firebase documentation is something we will be aiming to achieve in the near future. We're keen to move the project to TypeScript which will then allow us to generate reference documentation from those types.

However, if you are familiar with the Firebase JS SDK, it will be a much smoother process. React Native Firebase is using the same API as can be found on the official [Firebase JS SDK modular API documentation](https://firebase.google.com/docs/reference/js).

## Firestore example

## deprecated namespaced Query

```js
import firestore from '@react-native-firebase/firestore';

const db = firestore();

const querySnapshot = await db.collection("cities").where("capital", "==", true).get();

querySnapshot.forEach((doc) => {
console.log(doc.id, " => ", doc.data());
});
```

## modular Query

```js
import { collection, query, where, getDocs, getFirestore } from "@react-native-firebase/firestore";

const db = getFirestore();

const q = query(collection(db, "cities"), where("capital", "==", true));

const querySnapshot = await getDocs(q);

querySnapshot.forEach((doc) => {
console.log(doc.id, " => ", doc.data());
});
```

For more examples of requesting data, see the official Firebase documentation for [Get data with Cloud Firestore](https://firebase.google.com/docs/firestore/query-data/get-data). You will find code snippets for "Web namespaced API" and "Web modular API". You can find code snippets for both namespaced API and modular API through out the Firebase web documentation.
13 changes: 9 additions & 4 deletions packages/app/lib/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,11 @@ export function deprecationConsoleWarning(nameSpace, methodName, instanceName, i
const deprecatedMethod = instanceMap[methodName];
if (instanceMap && deprecatedMethod) {
const message = createMessage(nameSpace, methodName, instanceName);
// eslint-disable-next-line no-console
console.warn(message);

if (!globalThis.RNFB_SILENCE_V8_DEPRECATION_WARNINGS) {
// eslint-disable-next-line no-console
console.warn(message);
}
}
}
}
Expand Down Expand Up @@ -367,6 +370,8 @@ export function warnIfNotModularCall(args, replacementMethodName = '') {
message += ` Please use \`${replacementMethodName}\` instead.`;
}

// eslint-disable-next-line no-console
console.warn(message);
if (!globalThis.RNFB_SILENCE_V8_DEPRECATION_WARNINGS) {
// eslint-disable-next-line no-console
console.warn(message);
}
}
Loading