-
Notifications
You must be signed in to change notification settings - Fork 926
Failed to initialize auth with persistence: [Error: Component auth has not been registered yet] #8988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
I've been using this for the last 2 years with no problems until I upgraded as well. Did I miss something in an update? Fileimport AsyncStorage from "@react-native-async-storage/async-storage";
import { initializeApp } from "firebase/app";
import { initializeAuth, getReactNativePersistence } from "firebase/auth";
import getEnvVars from "./Environment";
/** Dynamically fetch environment variables. */
const { ENVIRONMENT } = getEnvVars();
/** Initializes the {@link firebase} application with configuration options. */
const FirebaseApp = initializeApp(
ENVIRONMENT === "production"
? require("./FirebaseConfig.prod.json")
: require("./FirebaseConfig.dev.json"),
);
/**
* This function allows more control over the Auth instance than getAuth, which uses platform-specific defaults to supply the Dependencies.
* In general, getAuth is the easiest way to initialize Auth and works for most use cases. Use initializeAuth if you need control over which
* persistence layer is used, or to minimize bundle size if you're not using either signInWithPopup or signInWithRedirect.
*
* @see https://firebase.google.com/support/release-notes/js#authentication
*/
const FirebaseAuth = initializeAuth(FirebaseApp, {
persistence: getReactNativePersistence(AsyncStorage),
});
/** Export the variables so the rest of the app can have access to them. */
export { FirebaseAuth, FirebaseApp }; I'm using the following related packages
|
I tried to use it in my React Native Expo project with Expo version 53. It causes the same problem. Then I tried with my older project (Expo SDK 52) and then it worked. I think the Firebase JS SDK needs an update for Expo SDK 53 and higher. |
Here's the bug on the expo side of things. Between firebase or expo, it must be something. I gotta switch off firebase if this continues |
Unresolved past issue here |
Im having the same issue, using Expo SDK 53.0.5 and firebase 11.6.1, it works fine on 52 |
it could possibly be related to metro enabling support for package.json:exports -- expo/expo#36551. try disabling it as described in that discussion topic |
Thanks @brentvatne. This resolved the issue for me. I've added it to the list https://github.com/expo/expo/discussions/36551#discussioncomment-13021826 |
Operating System
Mac OS
Environment (if applicable)
Expo 52 / React Native
Firebase SDK Version
11.6.1
Firebase SDK Product(s)
Auth
Project Tooling
Environment
firebase: 11.6.1
react-native: 0.79.1
expo: 53.0.1
@react-native-async-storage/async-storage: 2.1.2
Detailed Problem Description
When using the Firebase JS SDK (firebase@11.6.1) with React Native (react-native@0.79.1), initializing Auth without explicitly providing AsyncStorage results in:
The warning appears even though @react-native-async-storage/async-storage is installed.
The error [Error: Component auth has not been registered yet] is thrown on initialization.
This occurs when using the standard getAuth() import from firebase/auth.
Steps and code to reproduce issue
Install dependencies as above.
Initialize Firebase and Auth in a React Native project.
Observe the warning and error on app start.
Expected Behavior
Auth should initialize without error if AsyncStorage is installed.
If AsyncStorage is required, the SDK should detect and use it automatically, or provide clear instructions for React Native users.
The text was updated successfully, but these errors were encountered: