Angular Fire
The official Angular library for Firebase.
README
AngularFire
ng add @angular/fire
Example use
- ```ts
- import { provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
- import { getFirestore, provideFirestore } from '@angular/fire/firestore';
- @NgModule({
- imports: [
- provideFirebaseApp(() => initializeApp({ ... })),
- provideFirestore(() => getFirestore()),
- ],
- ...
- })
- export class AppModule { }
- ```
- ```ts
- import { Firestore, collectionData, collection } from '@angular/fire/firestore';
- import { Observable } from 'rxjs';
- interface Item {
- name: string,
- ...
- };
- @Component({
- selector: 'app-root',
- template: `
- <ul>
- <li *ngFor="let item of item$ | async">
- {{ item.name }}
- </li>
- </ul>
- `
- })
- export class AppComponent {
- item$: Observable<Item[]>;
- constructor(firestore: Firestore) {
- const collection = collection(firestore, 'items');
- this.item$ = collectionData(collection);
- }
- }
- ```
Compatibility
Angular and Firebase versions
Angular | Firebase | AngularFire |
---|---|---|
--------|----------|--------------| | ||
15 | 9 | ^7.5 |
14 | 9 | ^7.4 |
13 | 9 | ^7.2 |
12 | 9 | ^7.0 |
12 | 7,8 | ^6.1.5 |
11 | 7,8 | ^6.1 |
10 | 8 | ^6.0.4 |
10 | 7 | ^6.0.3 |
9 | 8 | ^6.0.4 |
9 | 7 | ^6.0 |
Polyfills
API | Environments | Suggested | License |
---|---|---|---|
|-----|--------------|--------------------|---------| | |||
Various | Safari | [`core-js/stable`](https://github.com/zloirock/core-js#readme) | MIT |
`globalThis` | [Chrome | [`globalThis`](https://github.com/es-shims/globalThis#readme) | MIT |
`Proxy` | [Safari | [`proxy-polyfill`](https://github.com/GoogleChrome/proxy-polyfill#readme) | Apache |
`fetch` | [Safari | [`cross-fetch`](https://github.com/lquixada/cross-fetch#readme) | MIT |
Resources
Sample apps
Having troubles?
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 <strong>best-effort basis</strong> by maintainers and other community members. If you are able to reproduce a problem with Firebase <em>outside of AngularFire's implementation</em>, please file an issue on the Firebase JS SDK or reach out to the personalized Firebase support channel.
Developer Guide
Monitor usage of your application in production
AngularFireAnalytics provides a convenient method of interacting with Google Analytics in your Angular application. The provided ScreenTrackingService and UserTrackingService automatically log events when you're using the Angular Router or Firebase Authentication respectively. Learn more about Google Analytics.
Interacting with your database(s)
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
Local Emulator Suite
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.
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.