firebaseui-web: Firebase UI is incompatible with Firebase SDK 9 (beta)
- Firebase UI version: 4.8.0
- Firebase SDK version: 0.900.19
Firebase SDK 9 is now released in beta. When testing with Firebase UI 4.8.0, it becomes clear that Firebase UI is not ready to be used with the modularized import api of Firebase SDK 9.
Steps to reproduce:
- Load Firebase UI with Firebase SDK 9:
import { getApp } from 'firebase/app'
import { getAuth } from 'firebase/auth'
import * as firebaseui from 'firebaseui';
const app = getApp();
const auth = getAuth(app);
uiConfig = (…)
new firebaseui.auth.AuthUI(auth).start('#firebaseui-auth-container', uiConfig);
- Experience TypeError, since
firebase
is undefined in firebaseui-web: https://github.com/firebase/firebaseui-web/blob/1a8f9e523f76df7a6c5da36b63b4d2a5b34b64ef/javascript/widgets/authui.js#L127
TypeError: Cannot read property 'initializeApp' of undefined
@davideast has commented on the issue over at https://github.com/firebase/firebase-js-sdk/discussions/4375#discussioncomment-330765 in February:
We don't have a version of Firebase UI available for the new SDK just yet. But hang tight!
I could not see the issue being tracked here, so therefore I’m posting it as a specific reproducible bug to track. (The theme is somewhat already addressed in #257, however there as a more general issue).
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 22
- Comments: 21 (6 by maintainers)
This is what worked for me. I am using webpack with a css loader so I can import css as shown below. First, npm install the latest firebase and firebaseui. Then the code looks like this:
Then I added an empty div with id=‘firebaseuiAuthContainer’ to my html where I wanted the sign in UI to show up.
It’s kind of weird because you have to use a hybrid v8/v9 way of getting auth and the UI. I finally found the above after digging for a long time in the firebase documentation, but I can’t find the link, or I would attach it. I agree that a clean v9 version of this feature is needed. Hope this helps!
Working on support over at #850 FYI.
Ok. Let’s hope it comes around soon. I would be really good if it comes around a week after Google IO. I’m terrible at CSS styling, and I don’t have a very big team to handle that work for me.
Documentation says:
Can you please explain how to do it, if at all possible?
Any more updates or progress on getting Firebase UI compatible with Firebase SDK 9?
Hey @johanrd, this is a known limitation (documented in official docs too). v9 is still in beta. We will update the README to also reflect this issue.
On one hand, there are now some new Firebase features, e.g. AppCheck support only V9. On the other hand, this FirebaseUI can only use compat sdk. Can someone from Angular (@sam-gc?) or Firebase (@jamesdaniels?) team comment on if/when will this be fixed? This would at least give the community a better idea if we should switch to something else. Thanks!
Having a tree-shaking JS is very important to reduce bandwidth and JS sizes which is better for the environement too (less impact on client memory, faster parsing time, etc etc).
After almost 2y after v9 release, I would have think this library was updated already but it is not 😕
Great. I can verify that firebaseui-web@0.6 *works* with the following versions:
…However: As I understand it, the expected bundle size reduction from the modularized import API of firebase@9 is still a distant dream as long as firebaseui@0.6 imports the whole shebang from
firebase/app
andfirebase/auth
. @jamesdaniels should I create other issues for this, or is that already part of the plan for firebaseui@0.6?:1) Make firebaseui utilize the modularized import API of firebase@9, e.g. something like:
2) Make the API of firebaseui-web itself modularized (as opposed to
import * as firebaseui from 'firebaseui'
), e.g. something like:…or have I misunderstood what is possible/viable here?
😢 Almost 2 years…
This is available for testing now,
npm i --save firebaseui@next firebase@next
I had to add
--legacy-peer-deps
to make the installation work. However, I have yet to make the compatibility work. One thing I’ve found is that you need to initialize the app using the compatibility API, otherwise it says you have not initialized the app. Even still, I’m getting an error in the console:export 'default' (imported as 'firebase') was not found in 'firebase/app'
I think this means that the library is trying to access the Firebase API directly and not just through the auth handle you pass to it. Not sure there’s much to be done for that until the devs support v9. Guess I’ll be rolling back for now. I did see this as a possible remedy, though I haven’t tried it: https://github.com/firebase/firebaseui-web/issues/722#issuecomment-735018681Could someone please post an example on how to get Firebaseauth UI to work with v9 with the compatibility layer? I’m getting stuck with this error and I suspect it’s because I’m not importing the libraries correctly: