Fix Firebase 'Component auth not registered yet' Error
Resolve 'Uncaught Error: Component auth has not been registered yet' in Firebase Auth for React Native/Expo. Use initializeAuth with AsyncStorage, Metro config fixes, and singleton patterns for reliable setup.
How to fix ‘Uncaught Error: Component auth has not been registered yet’ in Firebase? This error persists despite multiple attempts to resolve it.
Uncaught Error: Component auth has not been registered yet is a common firebase auth error in React Native/Expo projects caused by module-resolution/bundler issues or by initializing Auth before the native persistence is registered. The quickest fixes are to initialize Auth explicitly with initializeAuth + getReactNativePersistence(AsyncStorage), ensure a single (singleton) initialization, and, for Expo/Metro, add CJS support and disable package-exports resolution in metro.config.js.
Contents
- Quick fix: initializeAuth (firebase auth error)
- Metro / Expo bundler fix for “Component auth has not been registered yet”
- Singleton initialization and firebase auth (avoid re-init)
- Step-by-step troubleshooting checklist
- Advanced debugging and alternatives
- Sources
- Conclusion
Quick fix: initializeAuth (firebase auth error)
If your app uses the Firebase JS SDK in React Native / Expo, the most reliable immediate fix is to explicitly initialize Auth with the React Native persistence layer rather than relying on the web defaults. That means calling initializeAuth and passing getReactNativePersistence(AsyncStorage) instead of just getAuth().
Example (minimal):
// firebaseClient.js
import { initializeApp } from "firebase/app";
import { initializeAuth, getReactNativePersistence } from "firebase/auth";
import AsyncStorage from "@react-native-async-storage/async-storage";
const app = initializeApp(firebaseConfig);
const auth = initializeAuth(app, {
persistence: getReactNativePersistence(AsyncStorage)
});
export { app, auth };
Why this helps: the RN environment needs a native-compatible persistence backend (AsyncStorage). initializeAuth registers the platform-specific pieces the JS SDK expects; if it’s not called, the runtime may throw “Component auth has not been registered yet”. See the explicit fix reported in the Firebase issue where specifying AsyncStorage resolved the initialization error: https://github.com/firebase/firebase-js-sdk/issues/8988.
Tips:
- Import your
firebaseClient.jsonly from your app root so initialization runs once. - Make sure
@react-native-async-storage/async-storageis installed and the import matches your environment (Expo managed vs bare RN). - If you must support both web and RN builds, guard the RN code path (check Platform.OS or process.env) and fall back to
getAuth()on web.
Metro / Expo bundler fix for “Component auth has not been registered yet”
Sometimes the error isn’t your code at all but how Metro resolves Firebase’s package exports. Newer Firebase releases use package exports and ESM builds that Metro can mis-resolve, which means the auth component isn’t the one Firebase expects. The common workaround is to add CommonJS support and disable package-exports resolution in Metro.
metro.config.js (Expo / Metro workaround):
const { getDefaultConfig } = require('expo/metro-config');
module.exports = (() => {
const config = getDefaultConfig(__dirname);
config.resolver.sourceExts.push('cjs');
config.resolver.unstable_enablePackageExports = false;
return config;
})();
After editing metro.config.js:
- Stop the dev server and restart with cache cleared:
expo start -c(orreact-native start --reset-cachefor bare RN). - Rebuild native binary if using a device test build.
This exact Metro tweak was shared and validated in Expo issues and a practical blog post showing the fix: https://github.com/expo/expo/issues/36588 and https://pratikpathak.com/component-auth-has-not-been-registered-yet/. It forces Metro to pick the CommonJS entry and bypass the package exports resolution that can mis-route Firebase internals.
Heads-up: disabling package exports is a workaround. Keep an eye on upstream fixes from Expo/Firebase and revert the toggle when compatibility is restored.
Singleton initialization and firebase auth (avoid re-init)
Another frequent root cause: multiple or out-of-order initializations of Auth. If you call initialization code from multiple modules (or import firebase/auth too early), you can create a race that triggers the “Component auth has not been registered yet” error.
Use a single, central initializer and export the same Auth instance everywhere. Example using a global guard:
import { initializeApp } from "firebase/app";
import { initializeAuth, getReactNativePersistence, getAuth } from "firebase/auth";
import AsyncStorage from "@react-native-async-storage/async-storage";
const app = initializeApp(firebaseConfig);
let auth;
if (!global.__firebaseAuthInitialized) {
auth = initializeAuth(app, { persistence: getReactNativePersistence(AsyncStorage) });
global.__firebaseAuth = auth;
global.__firebaseAuthInitialized = true;
} else {
auth = global.__firebaseAuth || getAuth(app);
}
export { app, auth };
Why a global or module-level singleton? It prevents re-initialization across hot reloads, code-splitting boundaries, or when different parts of your app import the SDK at slightly different times. The Expo issue thread that documents singleton solutions is here: https://github.com/expo/expo/issues/36496.
Also confirm you’re not mixing two Firebase implementations (the JS SDK and the native react-native-firebase package). Choose one approach—mixing them can cause registering conflicts.
Step-by-step troubleshooting checklist
Follow these steps in order; each is quick to try and narrows the fault:
- Confirm which Firebase package you use:
- Run
npm ls firebaseandnpm ls @react-native-firebase/app. If both appear, you might be mixing SDKs — remove one.
- Ensure AsyncStorage is installed:
npm install @react-native-async-storage/async-storage(oryarn add ...) and import it from the same path in your code.
- Switch to explicit RN initialization:
- Replace plain
getAuth()usage withinitializeAuth(app, { persistence: getReactNativePersistence(AsyncStorage) }).
- Centralize initialization:
- Put init code in one file and export the single
authinstance (use the global guard pattern above).
- Fix Metro/Expo config if using Expo or Metro:
- Add
sourceExts.push('cjs')andunstable_enablePackageExports = falsetometro.config.jsand restart withexpo start -c. - Reference: https://github.com/expo/expo/issues/36588
- Clear caches and reinstall:
rm -rf node_modules && npm installexpo start -correact-native start --reset-cacheand rebuild the app.
- Check for duplicate versions:
yarn why firebaseornpm ls firebase— dedupe or lock versions in package.json if necessary.
- Toggle experimental RN features:
- If you recently enabled the new architecture or made changes to Hermes, try reverting those to isolate the problem (some reports mention toggling new architecture helped).
- Try a repro in a minimal project:
- Create a tiny RN/Expo app with only Firebase auth to see if the error reproduces. That isolates packaging vs app code causes.
- Search and follow related issues:
- If none of the above works, file a focused issue with a minimal repro and include Metro config, Firebase version, Expo/React Native versions, and full logs. Useful trackers: Firebase JS SDK issues and Expo issues.
If you want commands for environment info: npx react-native info and expo diagnostics can speed up debugging.
Advanced debugging and alternatives
Still stuck? try these advanced steps.
- Read packager logs (Metro) and device logs (adb logcat or Xcode) for the exact stack — sometimes the stack shows which module is loaded first.
- Try a targeted downgrade/upgrade: if a specific Firebase release plus your Metro version is the culprit, try a nearby version (some reported this around
firebase@11.xwith Expo SDK 53). - Consider alternatives: if the JS SDK proves fragile in your environment, evaluate react-native-firebase (the native SDK) as a longer-term solution (but don’t mix it with the JS SDK).
- Watch the upstream threads and patches: the issues that documented this behavior are tracked here — Firebase JS SDK issue: https://github.com/firebase/firebase-js-sdk/issues/8988 and Expo discussions: https://github.com/expo/expo/issues/36588. For Hermes-specific nuances see community write-ups like https://ran-bajra.medium.com/fixing-component-auth-has-not-been-registered-yet-in-react-native-firebase-auth-hermes-26480a12107d.
A final note: when a fix works locally but fails after a cloud build (EAS, CI), remember to ensure your build caches are cleared — the Metro tweak must be present in the built bundle, not just in your dev server.
Sources
- https://github.com/firebase/firebase-js-sdk/issues/8988
- https://github.com/expo/expo/issues/36588
- https://github.com/expo/expo/issues/36496
- https://pratikpathak.com/component-auth-has-not-been-registered-yet/
- https://ran-bajra.medium.com/fixing-component-auth-has-not-been-registered-yet-in-react-native-firebase-auth-hermes-26480a12107d
Conclusion
The “Component auth has not been registered yet” firebase error usually comes from bundler/module-resolution problems or from initializing Auth the wrong way in React Native. The fastest, most reliable fixes are explicit RN initialization with initializeAuth + getReactNativePersistence(AsyncStorage), enforcing a singleton Auth instance, and applying the Metro/Expo workaround (add ‘cjs’ and disable package exports) when needed. Follow the checklist above; if it still persists, gather a minimal repro and open an issue with the linked trackers so maintainers can patch the underlying compatibility problem.