ng add @angular/fire-AngularFire2 integrates Firebase's realtime observers and authentication with Angular2. +- **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. +- **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: +## Example use ```ts -import {Component} from 'angular2/core'; -import {AngularFire} from 'angularfire2'; -import {Observable} from 'rxjs/Observable'; - -@Component({ - selector: 'project-name-app', - providers: [], - templateUrl: 'app/project-name-app.html', - directives: [], - pipes: [] +import { provideFirebaseApp, initializeApp } from '@angular/fire/app'; +import { getFirestore, provideFirestore } from '@angular/fire/firestore'; + +export const appConfig: ApplicationConfig = { + providers: [ + provideFirebaseApp(() => initializeApp({ ... })), + provideFirestore(() => getFirestore()), + ... + ], + ... }) -export class MyApp { - items: Observable
| +#### [Analytics](docs/analytics.md#analytics) +```ts +import { } from '@angular/fire/analytics'; ``` -import {bootstrap} from 'angular2/platform/browser'; -import {App} from './app'; -import {FIREBASE_PROVIDERS} from 'angularfire2'; + | +-bootstrap(App, FIREBASE_PROVIDERS); +#### [Authentication](docs/auth.md#authentication) +```ts +import { } from '@angular/fire/auth'; ``` + | +
| -### defaultFirebase - -Define the root url for the library, to resolve relative paths. - -Type: `string` - -Usage: - +#### [Cloud Firestore](docs/firestore.md#cloud-firestore) +```ts +import { } from '@angular/fire/firestore'; ``` -import {bootstrap} from 'angular2/platform/browser'; -import {FIREBASE_PROVIDERS, defaultFirebase} from 'angularfire2'; + | +-bootstrap(App, [ - FIREBASE_PROVIDERS, - defaultFirebase('https://my.firebaseio.com') -]); +#### [Cloud Functions](docs/functions.md#cloud-functions) +```ts +import { } from '@angular/fire/functions'; ``` + | +
| -### FirebaseRef - -Injectable symbol to create a Firebase reference based on -the url provided by `FirebaseUrl`. - -Type: `Firebase` - -Usage: - -``` -import {Inject} from 'angular2/core'; -import {FirebaseRef} from 'angularfire2'; -... -class MyComponent { - constructor(@Inject(FirebaseRef) ref:Firebase) { - ref.on('value', this.doSomething); - } -} +#### [Cloud Messaging](docs/messaging.md#cloud-messaging) +```ts +import { } from '@angular/fire/messaging'; ``` + | +-### FirebaseUrl - -URL for the app's default Firebase database. - -Type: `string` - -Usage: - +#### [Cloud Storage](docs/storage.md#cloud-storage) +```ts +import { } from '@angular/fire/storage'; ``` -import {bootstrap} from 'angular2/platform/browser'; -import {Inject} from 'angular2/core'; -import {FirebaseUrl, FIREBASE_PROVIDERS, defaultFirebase} from 'angularfire2'; + | +
| -@Component({ - selector: 'app', - template: `{{ url }}` -}) -class App { - constructor(@Inject(FirebaseUrl) public url: string) {} -} - -bootstrap(App, [ - FIREBASE_PROVIDERS, - defaultFirebase('https://my.firebaseio.com') -]); +#### [Data Connect](docs/data-connect.md#data-connect) +```ts +import { } from '@angular/fire/data-connect'; ``` + | +
-### FirebaseAuth
-
-Injectable service for managing authentication state.
-
-#### Logging In
-To log in a user, call the `login` method on an instance of `FirebaseAuth` class. The method has
-the following two signatures:
-
-```typescript
-login(config?: AuthConfiguration): Promise |
+
| -@Component({ - selector: 'my-component' - templateUrl: 'my_template.html' -}) -export class MyApp { - constructor (private _auth: FirebaseAuth) {} - - public doLogin () { - // This will perform popup auth with google oauth and the scope will be email - // Because those options were provided through bootstrap to DI, and we're overriding the provider. - this._auth.login({ - provider: AuthProviders.Google - }); - } -} +#### [Realtime Database](docs/database.md#realtime-database) +```ts +import { } from '@angular/fire/database'; ``` + | +
-#### Subscribing to Authentication State
-
-Type: `class FirebaseAuth extends ReplaySubject You are logged in
- Please log in
- `
-})
-class App {
- constructor (@Inject(FirebaseAuth) public auth: FirebaseAuth) {}
-}
+#### [Remote Config](docs/remote-config.md#remote-config)
+```ts
+import { } from '@angular/fire/remote-config';
```
+ |
+
| -### FirebaseListObservable - -Subclass of rxjs `Observable` which also has methods for updating -list-like Firebase data. - -type: `class` - -additional methods: +#### [App Check](docs/app-check.md#app-check) +```ts +import { } from '@angular/fire/app-check'; +``` + | +-`add:(val) => void`: Add an element to the Firebase ref. +#### [AI Logic](docs/ai.md#ai-logic) +```ts +import { } from '@angular/fire/ai'; +``` + | +
+
+
+AngularFire ❱ Developer Guide ❱ Analytics
+
+
+# Analytics
+
+Google Analytics is an app measurement solution, available at no charge, that provides insight on app usage and user engagement.
+
+[Learn more](https://firebase.google.com/docs/analytics)
+
+## Dependency Injection
+
+As a prerequisite, ensure that `AngularFire` has been added to your project via
+```bash
+ng add @angular/fire
+```
+
+Provide an Analytics instance in the application's `app.config.ts`:
+
+```ts
+import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
+import { provideAnalytics, getAnalytics } from '@angular/fire/analytics';
+
+export const appConfig: ApplicationConfig = {
+ providers: [
+ provideFirebaseApp(() => initializeApp({ ... })),
+ provideAnalytics(() => getAnalytics()),
+ ...
+ ],
+ ...,
+}
+```
+
+Next inject `Analytics` into your component:
+
+```typescript
+import { Component, inject } from '@angular/core';
+import { Analytics } from '@angular/fire/analytics';
+
+@Component({ ... })
+export class UserProfileComponent {
+ private analytics = inject(Analytics);
+ ...
+}
+```
+
+## Firebase API
+
+AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
+
+Update the imports from `import { ... } from 'firebase/analytics'` to `import { ... } from '@angular/fire/analytics'` and follow the official documentation.
+
+[Getting Started](https://firebase.google.com/docs/analytics/get-started?platform=web) | [API Reference](https://firebase.google.com/docs/reference/js/analytics)
diff --git a/docs/app-check.md b/docs/app-check.md
new file mode 100644
index 000000000..557bf578a
--- /dev/null
+++ b/docs/app-check.md
@@ -0,0 +1,58 @@
+
+AngularFire ❱ Developer Guide ❱ App Check
+
+
+
+
+# App Check
+
+App Check helps protect your API resources from abuse by preventing unauthorized clients from accessing your backend resources. It works with both Firebase services, Google Cloud services, and your own APIs to keep your resources safe.
+
+[Learn More](https://firebase.google.com/docs/app-check)
+
+## Dependency Injection
+
+As a prerequisite, ensure that `AngularFire` has been added to your project via
+```bash
+ng add @angular/fire
+```
+
+Provide an App Check instance in the application's `app.config.ts`:
+
+```ts
+import { ApplicationConfig } from '@angular/core';
+import { provideFirebaseApp, initializeApp, getApp } from '@angular/fire/app';
+import { provideAppCheck, initializeAppCheck, ReCaptchaV3Provider } from '@angular/fire/app-check';
+
+export const appConfig: ApplicationConfig = {
+ providers: [
+ provideFirebaseApp(() => initializeApp({ ... })),
+ provideAppCheck(() => initializeAppCheck(getApp(), {
+ provider: new ReCaptchaV3Provider(/* configuration */),
+ })),
+ ...
+ ],
+ ...
+}
+```
+
+Next inject `AppCheck` it into your component:
+
+```ts
+import { Component, inject} from '@angular/core';
+import { AppCheck } from '@angular/fire/app-check';
+
+@Component({ ... })
+export class AppCheckComponent {
+ private appCheck = inject(AppCheck);
+ ...
+}
+```
+
+## Firebase API
+
+AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
+
+Update the imports from `import { ... } from 'firebase/app-check'` to `import { ... } from '@angular/fire/app-check'` and follow the official documentation.
+
+[Getting Started](https://firebase.google.com/docs/app-check/web/recaptcha-provider) | [API Reference](https://firebase.google.com/docs/reference/js/app-check)
diff --git a/docs/app-hosting.md b/docs/app-hosting.md
new file mode 100644
index 000000000..d72eca28b
--- /dev/null
+++ b/docs/app-hosting.md
@@ -0,0 +1,95 @@
+
+AngularFire ❱ Developer Guide ❱ Deploying SSR to Firebase App Hosting
+
+
+# Deploying a server-rendered app to Firebase App Hosting
+
+[Firebase App Hosting](https://firebase.google.com/docs/app-hosting) is Firebase's recommended way to deploy a server-side-rendered (SSR) Angular application. It builds your app in Google Cloud Build, runs the Node server, and serves it behind Google's CDN and proxy. This applies to either way of deploying to App Hosting, a connected GitHub repository or `firebase deploy` from your own machine; both build the same way and are affected the same way.
+
+This guide covers one thing that trips up almost every new SSR deployment: **the server can silently stop server-rendering and fall back to client-side rendering (CSR), with no error anywhere obvious.** It explains how to detect that in 30 seconds and how to fix it.
+
+## How to deploy
+
+If you have not deployed yet, follow Firebase's own guides: [Get started with App Hosting](https://firebase.google.com/docs/app-hosting/get-started) to connect a GitHub repository (App Hosting builds and deploys on every push), or [Alternative ways to deploy](https://firebase.google.com/docs/app-hosting/alt-deploy) to deploy with `firebase deploy` from your own machine. Both build your app the same way in Google Cloud Build. The rest of this guide covers an Angular-specific issue you can hit once your app is deployed either way.
+
+## The symptom: SSR silently downgrades to CSR
+
+A freshly deployed Angular SSR app usually *looks* fine in a browser, the page renders and works. But the server may be sending an almost-empty HTML shell and letting the browser do all the rendering. When that happens you lose the whole point of SSR: crawlers and link previews see no content, and first paint on slow devices is worse.
+
+There is no error in the deploy output and no error in the browser. The only trace is in your backend's server logs, which nothing prompts you to check.
+
+App Hosting runs on Cloud Run, not Cloud Functions, so its logs live in Cloud Logging:
+
+- In the Firebase console, open your backend and go to its **Logs** tab, then look at **Runtime logs**.
+- From a terminal, use `gcloud`:
+
+ ```bash
+ gcloud logging read 'resource.type=cloud_run_revision AND resource.labels.service_name=YOUR_BACKEND_ID' --project YOUR_PROJECT_ID --limit 10
+ ```
+
+See Firebase's [View logs and metrics](https://firebase.google.com/docs/app-hosting/logging) guide for more.
+
+## The 30-second check to run after every deploy
+
+Pick an SSR route (not an SSG/prerendered one) and fetch it:
+
+```bash
+curl -s https://YOUR-SITE/ | grep ng-server-context
+```
+
+Angular's server renderer stamps a `ng-server-context` attribute on the app's root element:
+
+- `ng-server-context="ssr"` - the route was server-rendered (SSR). This is what you want.
+- `ng-server-context="ssg"` - the route was prerendered (SSG). Fine in itself, but not the SSR path this guide is about.
+- **No `ng-server-context` at all** - the server returned a client-only shell and the browser is doing all the rendering. This is the silent CSR fallback described above, regardless of how the page looks in a browser.
+
+## Why it happens
+
+Angular's server engine only trusts the `X-Forwarded-*` headers a proxy attaches to a request when it is told to. App Hosting's proxy adds several of these headers (for example `x-forwarded-for` and `x-forwarded-proto`). If Angular does not trust the full set the platform sends, it treats the request as untrusted and de-optimizes to CSR on every request.
+
+
+
+## The Fix
+
+Two steps are needed together.
+
+**1. Update Angular to the latest patch:**
+
+```bash
+npm update @angular/core @angular/ssr
+```
+
+**2. Turn on proxy-header trust when you create the server engine.** In `src/server.ts`, pass `trustProxyHeaders: true` to `AngularNodeAppEngine`:
+
+```ts
+import { AngularNodeAppEngine } from '@angular/ssr/node';
+
+const angularApp = new AngularNodeAppEngine({
+ trustProxyHeaders: true,
+});
+```
+
+Redeploy, then run the 30-second check above. You should now see `ng-server-context="ssr"`.
+
+### Why both steps
+
+The two steps address different halves of the same handshake, and neither alone is enough:
+
+- Recent Angular patches let the `trustProxyHeaders` engine option take effect on App Hosting; on older patches a platform environment variable wins instead, so the code option is ignored. The `npm update` gets you onto a patch where the option is honored.
+- Even on the latest patch, you still have to *set* the option, so App Hosting's proxy headers are trusted.
+
+This matches Firebase's own guidance. For the current, authoritative version of this fix (including any App Hosting or Angular version notes), see Firebase's [App Hosting troubleshooting guide](https://firebase.google.com/docs/app-hosting/troubleshooting#angular-proxy-trust).
+
+> Note: App Hosting also has an experimental, opt-in local-build deploy option (you build on your own machine, then `firebase deploy`) in which the Firebase CLI applies this proxy-header configuration for you. It is off by default and not a documented, supported workflow, so this guide targets the standard source deploy; apply the fix above.
+
+## Related Angular documentation
+
+- [Angular SSR guide](https://angular.dev/guide/ssr)
+- [Configuring trusted proxy headers](https://angular.dev/best-practices/security#configuring-trusted-proxy-headers)
diff --git a/docs/auth.md b/docs/auth.md
new file mode 100644
index 000000000..c9654e397
--- /dev/null
+++ b/docs/auth.md
@@ -0,0 +1,204 @@
+
+
+
+AngularFire ❱ Developer Guide ❱ Authentication
+
+
+# Authentication
+
+Most apps need to know the identity of a user. Knowing a user's identity allows an app to securely save user data in the cloud and provide the same personalized experience across all of the user's devices.
+Firebase Authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users to your app. It supports authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more.
+
+Firebase Authentication integrates tightly with other Firebase services, and it leverages industry standards like OAuth 2.0 and OpenID Connect, so it can be easily integrated with your custom backend.
+
+[Learn more about Firebase Authentication](https://firebase.google.com/docs/auth)
+
+## Dependency Injection
+
+As a prerequisite, ensure that `AngularFire` has been added to your project via
+```bash
+ng add @angular/fire
+```
+
+Provide an Auth instance in the application's `app.config.ts`:
+
+```ts
+import { ApplicationConfig } from '@angular/core';
+import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
+import { provideAuth, getAuth } from '@angular/fire/auth';
+
+export const appConfig: ApplicationConfig = {
+ providers: [
+ provideFirebaseApp(() => initializeApp({ ... })),
+ provideAuth(() => getAuth()),
+ ...
+ ],
+ ...
+}
+```
+
+Next inject `Auth` into your component:
+
+```ts
+import { Component, inject} from '@angular/core';
+import { Auth } from '@angular/fire/auth';
+
+@Component({ ... })
+export class LoginComponent {
+ private auth = inject(Auth);
+ ...
+}
+```
+
+## Firebase API
+
+AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
+
+Update the imports from `import { ... } from 'firebase/auth'` to `import { ... } from '@angular/fire/auth'` and follow the official documentation.
+
+[Getting Started](https://firebase.google.com/docs/auth/web/start) | [API Reference](https://firebase.google.com/docs/reference/js/auth)
+
+## Server-side Rendering
+
+To support Auth context in server-side rendering, you can provide `FirebaseServerApp`:
+
+```ts
+import { ApplicationConfig, PLATFORM_ID, inject } from '@angular/core';
+import { isPlatformBrowser } from '@angular/common';
+import { provideFirebaseApp, initializeApp, initializeServeApp, initializeServerApp } from '@angular/fire/app';
+import { provideAuth, getAuth } from '@angular/fire/auth';
+
+export const appConfig: ApplicationConfig = {
+ providers: [
+ provideFirebaseApp(() => {
+ if (isPlatformBrowser(inject(PLATFORM_ID))) {
+ return initializeApp(firebaseConfig);
+ }
+ // Optional, since it's null in dev-mode and SSG
+ const request = inject(REQUEST, { optional: true });
+ const authIdToken = request?.headers.authorization?.split("Bearer ")[1];
+ return initializeServerApp(firebaseConfig, {
+ authIdToken,
+ releaseOnDeref: request || undefined
+ });
+ }),
+ provideAuth(() => getAuth(inject(FirebaseApp)),
+ ...
+ ],
+ ...
+})
+```
+
+Follow Firebase's [ Session Management with Service Workers documentation](https://firebase.google.com/docs/auth/web/service-worker-sessions) to learn how to pass the `idToken` to the server. __Note: this will not currently work in dev-mode as Angular SSR does not provide a method to get the Request headers.__
+
+## Convenience observables
+
+AngularFire provides observables to allow convenient use of the Firebase Authentication with RXJS.
+
+### user
+
+The `user` observable streams events triggered by sign-in, sign-out, and token refresh events.
+
+Example code:
+
+```ts
+import { Auth, User, user } from '@angular/fire/auth';
+...
+
+export class UserComponent implements OnDestroy {
+ private auth: Auth = inject(Auth);
+ user$ = user(this.auth);
+ userSubscription: Subscription;
+ ...
+
+ constructor() {
+ this.userSubscription = this.user$.subscribe((aUser: User | null) => {
+ //handle user state changes here. Note, that user will be null if there is no currently logged in user.
+ console.log(aUser);
+ })
+ }
+
+ ngOnDestroy() {
+ // when manually subscribing to an observable remember to unsubscribe in ngOnDestroy
+ this.userSubscription.unsubscribe();
+ }
+}
+
+```
+
+### authState
+
+The `authState` observable streams events triggered by sign-in and sign-out events.
+
+Example code:
+```ts
+import { Auth, authState } from '@angular/fire/auth';
+...
+
+export class UserComponent implements OnDestroy {
+ private auth: Auth = inject(Auth);
+ authState$ = authState(this.auth);
+ authStateSubscription: Subscription;
+ ...
+
+ constructor() {
+ this.authStateSubscription = this.authState$.subscribe((aUser: User | null) => {
+ //handle auth state changes here. Note, that user will be null if there is no currently logged in user.
+ console.log(aUser);
+ })
+ }
+
+ ngOnDestroy() {
+ // when manually subscribing to an observable remember to unsubscribe in ngOnDestroy
+ this.authStateSubscription.unsubscribe();
+ }
+}
+```
+
+### idToken
+
+The `idToken` observable streams events triggered by sign-in, sign-out and token refresh events.
+
+Example code:
+```ts
+import { Auth, idToken } from '@angular/fire/auth';
+...
+
+export class UserComponent implements OnDestroy {
+ private auth: Auth = inject(Auth);
+ idToken$ = idToken(this.auth);
+ idTokenSubscription: Subscription;
+ ...
+
+ constructor() {
+ this.idTokenSubscription = this.idToken$.subscribe((token: string | null) => {
+ //handle idToken changes here. Note, that token will be null if there is no currently logged in user.
+ console.log(token);
+ })
+ }
+
+ ngOnDestroy() {
+ // when manually subscribing to an observable remember to unsubscribe in ngOnDestroy
+ this.idTokenSubscription.unsubscribe();
+ }
+}
+```
+
+## Connecting the emulator suite
+
+```ts
+import { ApplicationConfig } from '@angular/core';
+import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
+import { connectAuthEmulator, getAuth, provideAuth } from '@angular/fire/auth';
+
+export const appConfig: ApplicationConfig = {
+ providers: [
+ provideFirebaseApp(() => initializeApp({ ... })),
+ provideAuth(() => {
+ const auth = getAuth();
+ connectAuthEmulator(auth, 'http://localhost:9099', { disableWarnings: true });
+ return auth;
+ }),
+ ]
+}
+```
diff --git a/docs/compat.md b/docs/compat.md
new file mode 100644
index 000000000..bd8721b25
--- /dev/null
+++ b/docs/compat.md
@@ -0,0 +1,70 @@
+# AngularFire
+The official [Angular](https://angular.dev/) library for [Firebase](https://firebase.google.com/).
+
+ng add @angular/fire+ +## Compatibility Developer Guide + +AngularFire has a new tree-shakable API, you're looking at the documentation for the compatability version of the library. [Find the new developer guide here](../README.md#developer-guide). + +[See the v7 upgrade guide for more information on this change.](version-7-upgrade.md). + +### 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](https://firebase.google.com/docs/analytics). + +- [Getting started with Google Analytics](compat/analytics/getting-started.md) + +### 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](https://firebase.google.com/docs/firestore/rtdb-vs-firestore). + +#### 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. + +- [Documents](compat/firestore/documents.md) +- [Collections](compat/firestore/collections.md) +- [Querying Collections](compat/firestore/querying-collections.md) +- [Offline data](compat/firestore/offline-data.md) + +#### 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. + +- [Objects](compat/rtdb/objects.md) +- [Lists](compat/rtdb/lists.md) +- [Querying lists](compat/rtdb/querying-lists.md) + +### Authenticate users + +- [Getting started with Firebase Authentication](compat/auth/getting-started.md) +- [Route users with AngularFire guards](compat/auth/router-guards.md) + +### Local Emulator Suite + +- [Getting started with Firebase Emulator Suite](compat/emulators/emulators.md) + +### Upload files + +- [Getting started with Cloud Storage](compat/storage/storage.md) + +### Receive push notifications + +- [Getting started with Firebase Messaging](compat/messaging/messaging.md) + +### **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](https://firebase.google.com/docs/remote-config). + +- [Getting started with Remote Config](compat/remote-config/getting-started.md) + +### 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](https://firebase.google.com/docs/perf-mon). + +- [Getting started with Performance Monitoring](compat/performance/getting-started.md) + +### Directly call Cloud Functions + +- [Getting started with Callable Functions](compat/functions/functions.md) diff --git a/docs/compat/analytics/getting-started.md b/docs/compat/analytics/getting-started.md new file mode 100644 index 000000000..3c5af8aaf --- /dev/null +++ b/docs/compat/analytics/getting-started.md @@ -0,0 +1,137 @@ +# Getting started with Google Analytics + +`AngularFireAnalytics` dynamically imports the `firebase/analytics` library and provides a promisified version of the [Firebase Analytics SDK (`firebase.analytics.Analytics`)](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html). + +> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md). + +### API: + +```ts +class AngularFireAnalytics { + updateConfig(options: {[key:string]: any}): Promise
Please login.
+ +
+traceUntil(
+ name: string,
+ test: (T) => Boolean,
+ options?: { orComplete?: true }
+)
+
+
+traceWhile(
+ name: string,
+ test: (T) => Boolean,
+ options?: { orComplete?: true }
+)
+
+{{ item.payload.key }}
+ {{ meta | async }}`
+})
+export class AppComponent {
+ meta: Observable
+
+
+AngularFire ❱ Developer Guide ❱ Realtime Database
+
+
+# Realtime Database
+
+Store and sync data with our NoSQL cloud database. Data is synced across all clients in realtime, and remains available when your app goes offline.
+
+The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. When you build cross-platform apps with our iOS, Android, and JavaScript SDKs, all of your clients share one Realtime Database instance and automatically receive updates with the newest data. [Learn more about the Realtime Database](https://firebase.google.com/docs/database).
+
+## Dependency Injection
+
+As a prerequisite, ensure that `AngularFire` has been added to your project via
+```bash
+ng add @angular/fire
+```
+
+Provide a Database instance in the application's `app.config.ts`:
+
+```ts
+import { ApplicationConfig } from '@angular/core';
+import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
+import { provideDatabase, getDatabase } from '@angular/fire/database';
+
+export const appConfig: ApplicationConfig = {
+ providers: [
+ provideFirebaseApp(() => initializeApp({ ... })),
+ provideDatabase(() => getDatabase()),
+ ...
+ ],
+ ...
+}
+```
+
+Next inject `Database` into your component:
+
+```ts
+import { Component, inject } from '@angular/core';
+import { Database } from '@angular/fire/database';
+
+@Component({...})
+export class DepartmentComponent {
+ private database = inject(Database);
+ ...
+}
+```
+
+## Firebase API
+
+AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
+
+Just change your imports from `import { ... } from 'firebase/database'` to `import { ... } from '@angular/fire/database'` and follow the official documentation.
+
+[Getting Started](https://firebase.google.com/docs/database/web/start) | [API Reference](https://firebase.google.com/docs/reference/js/database)
+
+## Convenience observables
+
+AngularFire provides observables to allow convenient use of the Realtime Database with RXJS.
+
+### `object`
+
+The `object()` function creates an observable that emits object changes.
+
+| | |
+|-----------------|------------------------------------------|
+| **function** | `object(ref)` |
+| **params** | ref: `Reference` |
+| **return** | `Observable
+
+
+AngularFire ❱ Developer Guide ❱ Cloud Firestore
+
+
+# Cloud Firestore
+
+Cloud Firestore is a flexible, scalable NoSQL database for mobile, web, and server development from Firebase and Google Cloud. It keeps your data in sync across client apps through realtime listeners and offers offline support for mobile and web so you can build responsive apps that work regardless of network latency or Internet connectivity.
+
+[Learn more](https://firebase.google.com/docs/firestore)
+
+Cloud Firestore is the API that gives your application access to your database in the cloud or locally in your [emulator](https://firebase.google.com/docs/emulator-suite).
+
+## Dependency Injection
+
+As a prerequisite, ensure that `AngularFire` has been added to your project via
+```bash
+ng add @angular/fire
+```
+Provide a Firestore instance in the application's `app.config.ts`:
+
+```ts
+import { ApplicationConfig } from '@angular/core';
+import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
+import { provideFirestore, getFirestore } from '@angular/fire/firestore';
+
+export const appConfig: ApplicationConfig = {
+ providers: [
+ provideFirebaseApp(() => initializeApp({ ... })),
+ provideFirestore(() => getFirestore()),
+ ...
+ ],
+ ...
+}
+```
+
+Next inject `Firestore` into your component:
+
+```typescript
+import { Component, inject } from '@angular/core';
+import { Firestore } from '@angular/fire/firestore';
+
+@Component({ ... })
+export class UserProfileComponent {
+ private firestore = inject(Firestore);
+ ...
+}
+```
+
+## Firebase API
+
+AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
+
+Update the imports from `import { ... } from 'firebase/firestore'` to `import { ... } from '@angular/fire/firestore'` and follow the official documentation.
+
+[Getting Started](https://firebase.google.com/docs/firestore/quickstart#web-modular-api) | [API Reference](https://firebase.google.com/docs/reference/js/firestore)
+
+### Reading data
+
+In Cloud Firestore data is stored in `documents` and `documents` are stored in `collections`. The path to data follows `