skip to Main Content

I am developing a React Native application using Expo and Firebase. I’m trying to use the createUserWithEmailAndPassword function to create a new user with email and password authentication. However, I’m encountering the following error:

TypeError: undefined is not a function, js engine: Hermes

This error seems to be related to the createUserWithEmailAndPassword function. I have been searching through the Expo and Firebase documentation, but I haven’t found a suitable solution yet. Here is the code I am using:

firebase.js:

import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";

const firebaseConfig = {
  apiKey:,
  authDomain: ,
  projectId: ,
  storageBucket: ,
  messagingSenderId: ,
  appId: ,
  measurementId:,
};

const app = initializeApp(firebaseConfig);
const auth = getAuth(app);

export default { auth };

SignUp.js:

import auth from "../firebase/firebase";

function createUser() {
  auth.createUserWithEmailAndPassword(email, password).then(() => {
    console.log("worked");
  });
}

Is there a compatibility issue between the Hermes JavaScript engine and the Firebase Web SDK? Or is there any other solution to this issue?

Any help would be appreciated!

2

Answers


  1. Chosen as BEST ANSWER

    In my firebase.js file, I changed the export statement to use named exports for the app and auth objects:

    // Initialize Firebase
    const app = initializeApp(firebaseConfig);
    const auth = getAuth(app);
    
    export { app, auth }; // Update this line to use named exports
    
    

    By using named exports and correctly importing the auth object, I was able to resolve the "TypeError: of undefined" error and successfully create a new user using Firebase authentication.


  2. const app = getYourFirebaseApp()
    const auth = getAuth(app);
    const result = await createUserWithEmailAndPassword(
            auth,
            email,
            password
          );
    

    this is its type

    createUserWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search