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 experience by conforming to Angular conventions.
ng add @angular/fire
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
import { getFirestore, provideFirestore } from '@angular/fire/firestore';
export const appConfig: ApplicationConfig = {
providers: [
provideFirebaseApp(() => initializeApp({ ... })),
provideFirestore(() => getFirestore()),
...
],
...
})
import { inject } from '@angular/core';
import { Firestore, collectionData, collection } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
interface Item {
name: string,
...
};
@Component({
selector: 'app-root',
standalone: true,
template: `
@for (item of (item$ | async); track item) {
{{ item.name }}
}
`
})
export class AppComponent {
item$: Observable<Item[]>;
firestore: Firestore = inject(Firestore);
constructor() {
const itemCollection = collection(this.firestore, 'items');
this.item$ = collectionData<Item>(itemCollection);
}
}
Neither AngularFire nor Firebase ship with polyfills. To have compatibility across a wide-range of environments, we suggest the following polyfills be added to your application:
API | Environments | Suggested Polyfill | License |
---|---|---|---|
Various ES5+ features | Safari < 10 | core-js/stable |
MIT |
globalThis |
Chrome < 71 Safari < 12.1 iOS < 12.2 Node < 12 |
globalThis |
MIT |
Proxy |
Safari < 10 | proxy-polyfill |
Apache 2.0 |
fetch |
Safari < 10.1 iOS < 10.3 |
cross-fetch |
MIT |
Quickstart - Get your first application up and running by following our quickstart guide.
Contributing
Stackblitz Template - Remember to set your Firebase configuration in app/app.module.ts
.
Upgrading to v7.0? Check out our guide.
We have three sample apps in this repository:
samples/compat
a kitchen sink application that demonstrates use of the "compatibility" APIsamples/modular
a kitchen sink application that demonstrates the new tree-shakable APIsamples/advanced
the same app as samples/modular
but demonstrates more advanced concepts such as Angular Universal state-transfer, dynamically importing Firebase feature modules, and Firestore data bundling.Get help on our Q&A board, the official Firebase Mailing List, the Firebase Community Slack (#angularfire2
), the Angular Community Discord (#firebase
), Gitter, the Firebase subreddit, or Stack Overflow.
NOTE: While relatively stable, AngularFire is a developer preview and is subject to change before general availability. 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.
This developer guide assumes you're using the new tree-shakable AngularFire API, if you're looking for the compatibility API you can find the documentation here.
See the v7 upgrade guide for more information on this change..
Analyticsimport { } from '@angular/fire/analytics'; |
Authenticationimport { } from '@angular/fire/auth'; |
Cloud Firestoreimport { } from '@angular/fire/firestore'; |
Cloud Functionsimport { } from '@angular/fire/functions'; |
Cloud Messagingimport { } from '@angular/fire/messaging'; |
Cloud Storageimport { } from '@angular/fire/storage'; |
Performance Monitoringimport { } from '@angular/fire/performance'; |
Realtime Databaseimport { } from '@angular/fire/database'; |
Remote Configimport { } from '@angular/fire/remote-config'; |
App Checkimport { } from '@angular/fire/app-check'; |
Vertex AIimport { } from '@angular/fire/vertexai-preview'; |