Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: (0 , _auth.getReactNativePersistence) is not a function

I am getting this error when trying to use getReactNativePersistence in Expo with React Native. "expo": "^49.0.0" and "firebase": "^10.3.0"

This is my code:

import AsyncStorage from "@react-native-async-storage/async-storage";
import { initializeApp } from "firebase/app";
import { initializeAuth, getReactNativePersistence } from "firebase/auth";
import { getFirestore } from "firebase/firestore";
import { getStorage } from "firebase/storage";

// Your web app's Firebase configuration
const firebaseConfig = {...};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = initializeAuth(app, {
  persistence: getReactNativePersistence(AsyncStorage),
});
const db = getFirestore(app);
const storage = getStorage(app);

export { auth, db, storage };

Error: TypeError: (0 , _auth.getReactNativePersistence) is not a function

I have tried both cases and it looks like getReactNativePersistence doesn't exist at all:

import { initializeAuth, getReactNativePersistence } from "firebase/auth";
import { getReactNativePersistence } from 'firebase/auth/react-native';
like image 442
drab Avatar asked Aug 29 '26 14:08

drab


1 Answers

Updating in case someone is using the latest version in 2024. I found a workaround for this on this comment in this issue here:

//@ts-ignore
import { getReactNativePersistence } from '@firebase/auth/dist/rn/index.js';
like image 127
Theo Oliveira Avatar answered Sep 01 '26 15:09

Theo Oliveira