Hey everyone, I'm building my first app using Expo and Google Identity Platform (GCP). I'm trying to set up persistent authentication, but I've hit a wall with TypeScript errors.
The Goal: I want to use getReactNativePersistence so that my users stay logged in after they close the app.
The Problem: When I try to import from firebase/auth, the function getReactNativePersistence is missing from the type declarations.
My Code (firebaseConfig.ts):
TypeScript
import { initializeApp } from "firebase/app";
import { initializeAuth, getReactNativePersistence } from "firebase/auth";
import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';
// GCP Config is here...
const app = initializeApp(firebaseConfig);
const auth = initializeAuth(app, {
persistence: getReactNativePersistence(ReactNativeAsyncStorage)
});
The Error: Module '"firebase/auth"' has no exported member 'getReactNativePersistence'.
What I've Tried:
-
Changing the import to
firebase/auth/react-native. Result:Cannot find module 'firebase/auth/react-native' or its corresponding type declarations. -
Adding a path mapping in
tsconfig.json. Result: No change. -
I have already installed @
react-native-async-storage/async-storage.
My Environment:
-
Expo SDK v54
-
Firebase v12.7
-
TypeScript
Does anyone know the "clean" way to fix this in 2025 without breaking the standard Firebase SDK structure? Is there a specifictsconfig change needed for Expo to recognize the /react-native export?