You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用AngularFireAuth初始化FirebaseUI组件?——AngularFire最新版本移除auth属性后的初始化报错问题

Fixing FirebaseUI Initialization with Latest AngularFire Versions

Since newer AngularFire versions (v7+) removed the direct auth property from AngularFireAuth, passing this.auth.auth to initialize FirebaseUI's AuthUI won't work anymore. Here's a straightforward fix:

Step 1: Retrieve the Native Firebase Auth Instance

AngularFire provides a helper method getAuth() to fetch the underlying Firebase Auth instance. First, import this method from @angular/fire/auth.

Step 2: Initialize FirebaseUI with the Native Instance

Use the retrieved native auth object to create your FirebaseUI AuthUI instance.

Here's your updated code:

import { Component, OnInit } from '@angular/core';
import { AngularFireAuth, getAuth } from '@angular/fire/auth';
import firebaseui from 'firebaseui';

@Component({
  // Your component metadata (selector, template, etc.) goes here
})
export class LoginComponent implements OnInit {
  ui!: firebaseui.auth.AuthUI;

  constructor(public auth: AngularFireAuth) { }

  ngOnInit() {
    // Get the native Firebase Auth instance
    const nativeAuth = getAuth();
    // Initialize FirebaseUI with the native instance
    this.ui = new firebaseui.auth.AuthUI(nativeAuth);

    // Add your FirebaseUI configuration here (example below)
    // this.ui.start('#firebaseui-auth-container', {
    //   signInOptions: [firebase.auth.EmailAuthProvider.PROVIDER_ID],
    //   signInSuccessUrl: '/'
    // });
  }
}

Quick Notes:

  • Double-check that your app module has been properly initialized with AngularFire and your Firebase project config.
  • Ensure your FirebaseUI version matches the Firebase SDK version bundled with AngularFire to avoid compatibility issues.

内容的提问来源于stack exchange,提问作者sumit kushwah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 10:42:44