-
Notifications
You must be signed in to change notification settings - Fork 981
Description
Operating System
Development OS: macOS 15.6.1 (Sequoia) Target Platforms: iOS and Android
Environment (if applicable)
React Native
Firebase SDK Version
12.4.0
Firebase SDK Product(s)
Auth
Project Tooling
Expo SDK 53.0.23 (React Native 0.79.6)
Detailed Problem Description
Problem Description
What I was trying to achieve
I'm trying to initialize Firebase Auth in my React Native (Expo) app with React Native persistence using AsyncStorage, following the Firebase documentation for React Native setup.
What actually happened
TypeScript throws a compilation error when attempting to import getReactNativePersistence
from firebase/auth
:
Module '"firebase/auth"' has no exported member 'getReactNativePersistence'.ts(2305)
Code that's failing
import { Auth, connectAuthEmulator, initializeAuth, getReactNativePersistence } from 'firebase/auth';
Error message
Module '"firebase/auth"' has no exported member 'getReactNativePersistence'.ts(2305)
Expected behavior
According to Firebase documentation, getReactNativePersistence
should be importable from firebase/auth
(or firebase/auth/react-native
) to enable persistent authentication in React Native apps.
Additional context
- The TypeScript compiler cannot find this export in the type definitions
- This blocks the ability to properly configure Firebase Auth persistence in React Native
- No runtime errors occur if I ignore the TypeScript error, suggesting the function exists at runtime but is missing from type definitions
Steps and code to reproduce issue
Steps to Reproduce
-
Create a new Expo project with TypeScript:
npx create-expo-app@latest my-app --template blank-typescript cd my-app
-
Install Firebase and AsyncStorage:
npm install firebase @react-native-async-storage/async-storage
-
Create a Firebase config file (
firebase.config.ts
):import { initializeApp } from 'firebase/app'; import { initializeAuth, getReactNativePersistence } from 'firebase/auth'; import AsyncStorage from '@react-native-async-storage/async-storage'; const firebaseConfig = { apiKey: "your-api-key", authDomain: "your-auth-domain", projectId: "your-project-id", // ... other config }; const app = initializeApp(firebaseConfig); // This line triggers the TypeScript error const auth = initializeAuth(app, { persistence: getReactNativePersistence(AsyncStorage) }); export { auth };
-
Run TypeScript check:
npx tsc --noEmit
-
Observe the error:
Module '"firebase/auth"' has no exported member 'getReactNativePersistence'.ts(2305)
Minimal Code Snippet
import { initializeAuth, getReactNativePersistence } from 'firebase/auth';
import AsyncStorage from '@react-native-async-storage/async-storage';
// TypeScript error occurs on this import ↑
// TS2305: Module '"firebase/auth"' has no exported member 'getReactNativePersistence'
Package Versions (from package.json)
{
"firebase": "^12.4.0",
"react-native": "0.79.6",
"expo": "~53.0.23",
}