# AngularFire AngularFire smooths over the rough edges an Angular developer might encounter when implementing the framework-agnostic [Firebase JS SDK](https://github.com/firebase/firebase-js-sdk) & aims to provide a more natural developer experience by conforming to Angular conventions.
ng add @angular/fire
- **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 real-time streams. - **NgRx friendly API** - Integrate with NgRx using AngularFire's action based APIs. - **Lazy-loading** - AngularFire dynamically imports much of Firebase, reducing the time to load your app. - **Google Analytics** - Zero-effort Angular Router awareness in Google Analytics. - **Router Guards** - Guard your Angular routes with built-in Firebase Authentication checks. ## Example use ```ts import { ApplicationConfig } from '@angular/core'; import { provideFirebaseApp, initializeApp } from '@angular/fire/app'; import { getFirestore, provideFirestore } from '@angular/fire/firestore'; export const appConfig: ApplicationConfig = { providers: [ provideFirebaseApp(() => initializeApp({ /* ...your Firebase config... */ })), provideFirestore(() => getFirestore()), // ... ], // ... } ``` ```ts import { AsyncPipe } from '@angular/common'; import { Component, inject } from '@angular/core'; import { Firestore, FirestoreDataConverter, collectionData, collection } from '@angular/fire/firestore'; interface Item { name: string; } // Types the collection and checks every document on its way in const itemConverter: FirestoreDataConverter = { toFirestore: item => item, fromFirestore: (snapshot, options) => { const data = snapshot.data(options); return { name: typeof data['name'] === 'string' ? data['name'] : '' }; }, }; @Component({ selector: 'app-root', template: ` `, imports: [AsyncPipe] }) export class App { firestore = inject(Firestore); itemCollection = collection(this.firestore, 'items').withConverter(itemConverter); items$ = collectionData(this.itemCollection); // Observable } ``` The converter is what gives the read its type. `collection()` alone returns an untyped reference. See [Typed reads](docs/firestore.md#typed-reads). ## Resources [Quickstart](docs/install-and-setup.md) - Get your first application up and running by following our quickstart guide. [Deploying SSR to App Hosting](docs/app-hosting.md) - Deploy a server-rendered app to Firebase App Hosting, and avoid the silent SSR-to-CSR fallback. [Contributing](CONTRIBUTING.md) [Stackblitz Template](https://stackblitz.com/edit/angular-fire-start) - A runnable AngularFire example. Add your own Firebase configuration to connect it to your project. [Upgrading from v6.0? Check out our guide.](docs/version-7-upgrade.md) [Upgrading from AngularFire 20? See the v21 upgrade guide.](docs/version-21-upgrade.md) [Upgrading from AngularFire 21? See the v22 upgrade guide.](docs/version-22-upgrade.md) ### Sample app The [`sample`](sample) folder contains a kitchen sink application that demonstrates use of the "modular" API, in a zoneless server-rendered application, with all the bells and whistles. ### Having troubles? Get help on our [Q&A board](https://github.com/angular/angularfire/discussions?discussions_q=category%3AQ%26A), the official [Firebase Mailing List](https://groups.google.com/forum/#!forum/firebase-talk), the [Firebase Community Slack](https://firebase.community/) (`#angularfire2`), the [Angular Community Discord](http://discord.gg/angular) (`#firebase`), [Gitter](https://gitter.im/angular/angularfire2), the [Firebase subreddit](https://www.reddit.com/r/firebase), or [Stack Overflow](https://stackoverflow.com/questions/tagged/angularfire2). > **NOTE:** 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](https://github.com/firebase/firebase-js-sdk/issues) or reach out to the personalized [Firebase support channel](https://firebase.google.com/support/). ## Developer Guide 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](docs/compat.md). [See the v7 upgrade guide for more information on this change.](docs/version-7-upgrade.md). ### Firebase product integrations
#### [AI Logic](docs/ai.md#ai-logic) ```ts import { } from '@angular/fire/ai'; ``` #### [Analytics](docs/analytics.md#analytics) ```ts import { } from '@angular/fire/analytics'; ```
#### [App Check](docs/app-check.md#app-check) ```ts import { } from '@angular/fire/app-check'; ``` #### [Authentication](docs/auth.md#authentication) ```ts import { } from '@angular/fire/auth'; ```
#### [Cloud Firestore](docs/firestore.md#cloud-firestore) ```ts import { } from '@angular/fire/firestore'; ``` #### [Cloud Functions](docs/functions.md#cloud-functions) ```ts import { } from '@angular/fire/functions'; ```
#### [Cloud Messaging](docs/messaging.md#cloud-messaging) ```ts import { } from '@angular/fire/messaging'; ``` #### [Cloud Storage](docs/storage.md#cloud-storage) ```ts import { } from '@angular/fire/storage'; ```
#### [Data Connect](docs/data-connect.md#data-connect) ```ts import { } from '@angular/fire/data-connect'; ``` #### [Performance Monitoring](docs/performance.md#performance-monitoring) ```ts import { } from '@angular/fire/performance'; ```
#### [Realtime Database](docs/database.md#realtime-database) ```ts import { } from '@angular/fire/database'; ``` #### [Remote Config](docs/remote-config.md#remote-config) ```ts import { } from '@angular/fire/remote-config'; ```