gladly-team / next-firebase-auth

Simple Firebase authentication for all Next.js rendering strategies
https://nfa-example-git-v1x-gladly-team.vercel.app/
MIT License
1.35k stars 290 forks source link

FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app-compat/no-app). #467

Closed G-Nation closed 2 years ago

G-Nation commented 2 years ago

Describe the bug I get the FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app-compat/no-app) when i call the FirebaseAuth.js component on any page. The code of the FirebaseAuth.js component is the same as in the example. I only changed this two imports: import firebase from 'firebase/compat/app'; import 'firebase/compat/auth';

Versions

"firebase": "^9.7.0",
"firebaseui": "^6.0.1",
"next": "12.1.5",
"next-absolute-url": "^1.2.2",
"next-firebase-auth": "^1.0.0-canary.8",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-firebase-hooks": "^5.0.3",
"react-firebaseui": "^6.0.0"

To Reproduce Steps to reproduce the behavior: I have an login.js page were I call the FirebaseAuth.js component and thats all the code i have on it. The code of the component is the same as in the example.

kmjennison commented 2 years ago

The v1 canary isn't intended to support Firebase compat mode. You can initialize Firebase yourself with compat mode before initializing next-firebase-auth and it should work, though I haven't tested this to confirm.

G-Nation commented 2 years ago

But if i dont use the compat mode of Firebase the "firebase.auth.EmailAuthProvider.PROVIDER_ID" is not recognized as a fuction. I'll try to initialize firebase on the initAuth.js file.

kmjennison commented 2 years ago

Have you taken a look at at the v1.x (canary) version of the demo app? It uses EmailAuthProvider with modular Firebase: https://github.com/gladly-team/next-firebase-auth/tree/v1.x/example

G-Nation commented 2 years ago

Thank you!! The code from de v1.x branch was the solution