@angular/fire
is the official integration packageimport {AngularFireModule} from '@angular/fire';
import {AngularFireAnalyticsModule} from '@angular/fire/analytics';
import {AngularFireAuthModule} from '@angular/fire/auth';
import {AngularFireDatabaseModule} from '@angular/fire/database';
import {environment} from 'src/environments/environment';
...
// in the NgModule imports
AngularFireModule.initializeApp(environment.firebase),
AngularFireAnalyticsModule,
AngularFireAuthModule,
AngularFireDatabaseModule,
You can then inject and use instances from any of the imported modules
private readonly fireAuth: AngularFireAuth
fireAuth.user
is an observable of the current user
fireAuth.currentUser
is a plain object
I think this effectively auto-logs in users with Google
fireAuth.onAuthStateChanged((user: User|null) => {
if (!user) {
fireAuth.signInWithPopup(new auth.GoogleAuthProvider());
}
});