AngularFire
The official Angular library for Firebase.
ng add @angular/fire
AngularFire smooths over the rough edges an Angular developer might encounter when implementing the framework-agnostic Firebase JS SDK & aims to provide a more natural developer expirience by conforming to Angular conventions.
- Dependency injection - Provide and Inject Firebase services in your components
- Zone.js wrappers - Stable zones allow proper functionality of service workers, forms, SSR, and pre-rendering
- Observable based - Utilize RxJS rather than callbacks for realtime streams
- NgRx friendly API - Integrate with NgRx using AngularFire's action based APIs.
- Lazy-loading - AngularFire dynamically imports much of Firebase, reducing time to load your app
- Deploy schematics - Get your Angular application deployed on Firebase Hosting with a single command
- Google Analytics - Zero-effort Angular Router awareness in Google Analytics
- Router Guards - Guard your Angular routes with built-in Firebase Authentication checks
Example use
import { Component } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
@Component({
selector: 'app-root',
template: `
<ul>
<li *ngFor="let item of item$ | async">
{{ item.name }}
</li>
</ul>
`
})
export class MyApp {
item$: Observable<any[]>;
constructor(firestore: AngularFirestore) {
this.item$ = firestore.collection('items').valueChanges();
}
}
Compatibility
Angular | Firebase | AngularFire |
---|---|---|
10 | 8 | ^6.0.4 |
10 | 7 | ^6.0.3 |
9 | 8 | ^6.0.4 |
9 | 7 | ^6.0 |
8 | 7 | ^5.2.3 |
8 | 6 | ^5.2.0 |
Version combinations not documented here may work but are untested and you will see NPM peer warnings.
Resources
Quickstart - Get your first application up and running by following our quickstart guide.
Stackblitz Template - Remember to set your Firebase configuration in app/app.module.ts
.
Upgrading to v6.0? Check out our guide.
Having troubles? Get help on the official Firebase Mailing List, the Firebase Community Slack (#angularfire2
), the Angular Community Discord (#firebase
), Gitter, or Stack Overflow.
NOTE: AngularFire is maintained by Googlers but is not a supported Firebase product. Questions on the mailing list and issues filed here are answered on a best-effort basis by maintainers and other community members. If you are able to reproduce a problem with Firebase outside of AngularFire's implementation, please file an issue on the Firebase JS SDK or reach out to the personalized Firebase support channel.
Developer Guide
NEW: Monitor usage of your application in production
AngularFireAnalytics
provides a convient method of interacting with Google Analytics in your Angular application. The providedScreenTrackingService
andUserTrackingService
automatically log events when you're using the Angular Router or Firebase Authentication respectively. Learn more about Google Analytics.
Interacting with your database(s)
Firebase offers two cloud-based, client-accessible database solutions that support realtime data syncing. Learn about the differences between them in the Firebase Documentation.
Cloud Firestore
AngularFirestore
allows you to work with Cloud Firestore, the new flagship database for mobile app development. It improves on the successes of Realtime Database with a new, more intuitive data model. Cloud Firestore also features richer, faster queries and scales better than Realtime Database.
Realtime Database
AngularFireDatabase
allows you to work with the Realtime Database, Firebase's original database. It's an efficient, low-latency solution for mobile apps that require synced states across clients in realtime.
Authenticate users
Upload files
Receive push notifications
BETA: Change behavior and appearance of your application without deploying
Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update. Learn more about Remote Config.
NEW: Monitor your application performance in production
Firebase Performance Monitoring is a service that helps you to gain insight into the performance characteristics of your iOS, Android, and web apps. Learn more about Performance Monitoring.
Directly call Cloud Functions
Deploying your application
Firebase Hosting is production-grade web content hosting for developers. With Hosting, you can quickly and easily deploy web apps and static content to a global content delivery network (CDN) with a single command.
Server-side rendering
Angular Universal is a technology that allows you to run your Angular application on a server. This allows you to generate your HTML in a process called server-side rendering (SSR). Angularfire is compatible with server-side rendering; allowing you to take advantage of the Search Engine Optimization, link previews, the performance gains granted by the technology, and more. Learn more about Angular Universal.
- Getting started with Angular Universal
- Deploying your Universal application on Cloud Functions for Firebase
- Prerendering your Universal application