Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4133 pages
Flutter and app store releases

React Native Firebase fills the console with 'This method is deprecated' warnings

Your error

This method is deprecated (as well as all React Native Firebase namespaced API) and will be removed in the next major release as part of move to match Firebase Web modular SDK API. Please see migration guide for more details: https://rnfirebase.io/migrating-to-v221 more line it can show

Fix it fast

Most common cause, 1 of 3

Your code uses the namespaced call style

Import the modular functions and pass the service object to them.

Fix
// before
// import auth from '@react-native-firebase/auth'
// await auth().signInWithEmailAndPassword(email, password)

// after
import { getAuth, signInWithEmailAndPassword, onAuthStateChanged } from '@react-native-firebase/auth'
import { getFirestore, collection, query, where, getDocs } from '@react-native-firebase/firestore'

const auth = getAuth()
await signInWithEmailAndPassword(auth, email, password)
onAuthStateChanged(auth, user => console.log(user?.uid))

const db = getFirestore()
const snap = await getDocs(query(collection(db, 'cities'), where('capital', '==', true)))
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Since v22, React Native Firebase logs a warning for every call made through the old namespaced style, such as auth().signInWithEmailAndPassword() or firestore().collection(), because that API is being removed in favour of the modular functions the Firebase web SDK uses. Rewrite each call as getAuth(), getFirestore() plus the matching function. A global flag can hide the warnings while you migrate.

  • Applies to @react-native-firebase/app 22.4 and 23.8, @react-native-firebase/auth 22.4
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

List the namespaced calls in your code. Each line that calls a module as a function, like auth() or firestore(), is one item to migrate.

Run this first
grep -rnE "(auth|firestore|messaging|storage|database|analytics|crashlytics|functions|remoteConfig)\(\)\." src app 2>/dev/null
grep -rn "firebase.app()" src app 2>/dev/null

Then find the line you see in this list and open its fix:

  1. 1Your code uses the namespaced call styleThe warning points at code like auth().signInWithEmailAndPassword(email, pw) or firestore().collection('cities')
  2. 2You cannot tell which call triggers each warningDozens of identical warnings appear and none shows a useful line number
  3. 3You need a quiet console while the migration is in progressThe warnings hide real errors during development

What does the error look like?

  • This method is deprecated (as well as all React Native Firebase namespaced API) and will be removed in the next major release as part of move to match Firebase Web modular SDK API. Please see migration guide for more details: https://rnfirebase.io/migrating-to-v22
  • Error: Deprecated API usage detected while in strict mode.

Cause 1 of 3

Your code uses the namespaced call style

You seeThe warning points at code like auth().signInWithEmailAndPassword(email, pw) or firestore().collection('cities')

Check

The v22 migration guide says the namespaced API is being removed and that the modular API matches the Firebase JS SDK, so the Firebase web documentation's modular snippets apply. The pattern is the same for every call: get the service instance, then pass it to an imported function.

Check
grep -rn "from '@react-native-firebase/" src app | grep -v "{"

Fix

Import the modular functions and pass the service object to them.

Fix
// before
// import auth from '@react-native-firebase/auth'
// await auth().signInWithEmailAndPassword(email, password)

// after
import { getAuth, signInWithEmailAndPassword, onAuthStateChanged } from '@react-native-firebase/auth'
import { getFirestore, collection, query, where, getDocs } from '@react-native-firebase/firestore'

const auth = getAuth()
await signInWithEmailAndPassword(auth, email, password)
onAuthStateChanged(auth, user => console.log(user?.uid))

const db = getFirestore()
const snap = await getDocs(query(collection(db, 'cities'), where('capital', '==', true)))

Verify

Exercise the screen again; that call no longer logs the deprecation warning.

Verify
npx react-native start   # watch the Metro log while you use the screen

Confirmed by rnfirebase.io

Did this fix it?

Cause 2 of 3

You cannot tell which call triggers each warning

You seeDozens of identical warnings appear and none shows a useful line number

Check

The guide describes a strict mode that throws instead of warning. In the package source, the warning path raises 'Deprecated API usage detected while in strict mode.' when the flag is on, and the stack trace then points at the calling line.

Check
grep -rn "RNFB_MODULAR_DEPRECATION_STRICT_MODE" index.js App.tsx 2>/dev/null

Fix

Turn on strict mode in development only, fix the line each crash points to, then turn it off.

Fix
// index.js, before any Firebase import is used
if (__DEV__) {
  globalThis.RNFB_MODULAR_DEPRECATION_STRICT_MODE = true
}

Verify

With strict mode on, the app runs through every screen without throwing.

Verify
npx react-native run-android

Confirmed by rnfirebase.io

Did this fix it?

Cause 3 of 3

You need a quiet console while the migration is in progress

You seeThe warnings hide real errors during development

Check

The same guide documents a global flag that switches the warning logs off. It must be set before Firebase is initialized; it hides the messages but changes nothing about the deprecation itself.

Check
grep -rn "RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS" . --include=*.js --include=*.ts --include=*.tsx | grep -v node_modules

Fix

Set the flag at the very top of the entry file and keep a ticket to remove it once the code is modular.

Fix
// index.js (first lines)
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true

Verify

Reload the app; the deprecation lines are gone from the log.

Verify
npx react-native start --reset-cache

Confirmed by rnfirebase.io

Did this fix it?

How do I stop it coming back?

  • Write all new Firebase code in the modular style, copying from the web SDK's modular snippets.
  • Migrate one Firebase service at a time and keep the app releasable after each one.
  • Read the migration guide for every React Native Firebase major you install; removals arrive service by service.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.