Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

347
Views
React Native - TypeError: _firebase.default.auth is not a function

I have a React Native App and have the following function:

import firebase from './firebase'

export function MainNavigator() {
  const [token, setToken] = useAtom(tokenAtom);

  useEffect(() => {
    firebase.auth().onIdTokenChanged(async (user) => {
      setToken(user ? await user.getIdToken() : null);
    });
  }, []);
  .....
  .... more code

This above code worked in Expo, but I have a new react native project (not built using expo) and this is failing:

I have the following in my package.json file:

"@react-native-firebase/app": "^13.0.1",
"@react-native-firebase/functions": "^13.0.1",
"firebase": "^9.5.0",

And my firebase.js file is like so (root directory)

import * as firebase from "firebase/app";

// Your web app's Firebase configuration
var firebaseConfig = {
    apiKey: "Secret stuff",
    authDomain: "Secret stuff",
    databaseURL: "Secret stuff",
    projectId: "Secret stuff",
    storageBucket: "Secret stuff",
    messagingSenderId: "Secret stuff",
    appId: "Secret stuff",
    measurementId: "Secret stuff"
};

// Initialize Firebase
firebase.initializeApp(firebaseConfig);

export default firebase;

Im getting the following error:

TypeError: _firebase.default.auth is not a function. (In '_firebase.default.auth()', '_firebase.default.auth' is undefined)

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

None of the code you show imports the Firebase Authentication SDK. So when you then try to use firebase.auth() it correctly indicates that it can't find that SDK.

I'm guessing you want to import the Auth SDK too with something like:

import "firebase/auth";

I'd also recommend checking out the documentation on upgrading to the v9 or v9/compat SDK.

about 4 years ago · Juan Pablo Isaza Report

0

// v9 compat packages are API compatible with v8 code

import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';

docs

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!