diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..f1cc3ad32
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+# http://editorconfig.org
+
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 2
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+insert_final_newline = false
+trim_trailing_whitespace = false
diff --git a/.firebaserc b/.firebaserc
new file mode 100644
index 000000000..c0bfb3028
--- /dev/null
+++ b/.firebaserc
@@ -0,0 +1,5 @@
+{
+ "projects": {
+ "default": "angularfire2-test"
+ }
+}
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 000000000..772bfbbb9
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,5 @@
+src/**/firebase.ts linguist-generated=true
+src/**/rxfire.ts linguist-generated=true
+src/compat/**/base.ts linguist-generated=true
+samples/**/* linguist-generated=true
+yarn.lock linguist-generated=true
\ No newline at end of file
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
new file mode 100644
index 000000000..a1fbcb71c
--- /dev/null
+++ b/.github/workflows/codeql-analysis.yml
@@ -0,0 +1,67 @@
+# For most projects, this workflow file will not need changing; you simply need
+# to commit it to your repository.
+#
+# You may wish to alter this file to override the set of languages analyzed,
+# or to provide custom queries or build logic.
+#
+# ******** NOTE ********
+# We have attempted to detect the languages in your repository. Please check
+# the `language` matrix defined below to confirm you have the correct set of
+# supported CodeQL languages.
+#
+name: "CodeQL"
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: [ main ]
+ schedule:
+ - cron: '20 23 * * 3'
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ 'javascript' ]
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
+ # Learn more:
+ # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ languages: ${{ matrix.language }}
+ # If you wish to specify custom queries, you can do so here or in a config file.
+ # By default, queries listed here will override any specified in a config file.
+ # Prefix the list here with "+" to use these queries and those in the config file.
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
+
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
+ # If this step fails, then you should remove it and run the build manually (see below)
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@v2
+
+ # ℹ️ Command-line programs to run using the OS shell.
+ # 📚 https://git.io/JvXDl
+
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
+ # and modify them (or add more) to build your code if your project
+ # uses a compiled language
+
+ #- run: |
+ # make bootstrap
+ # make release
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 000000000..ebb9d9b3e
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,220 @@
+name: Test and publish
+
+on:
+ push:
+ branches:
+ - main
+ paths-ignore:
+ - "**/*.md"
+ pull_request:
+ branches:
+ - "**"
+ release:
+ types:
+ - published
+ schedule:
+ - cron: 0 0 * * 1-5
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ name: Build
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ - name: Setup node
+ uses: actions/setup-node@v3
+ with:
+ node-version: '20'
+ check-latest: false
+ - name: angular build cache
+ uses: actions/cache@v3
+ with:
+ path: ./.angular
+ key: angular-cache
+ - name: node_modules cache
+ uses: actions/cache@v3
+ id: node_modules_cache
+ with:
+ path: ./node_modules
+ key: ${{ runner.os }}-20-${{ hashFiles('package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-20-
+ - name: Install deps
+ if: steps.node_modules_cache.outputs.cache-hit != 'true'
+ run: |
+ npm ci
+ - name: Build
+ run: ./tools/build.sh
+ - name: 'Upload Artifact'
+ uses: actions/upload-artifact@v4
+ with:
+ name: angularfire-${{ github.run_id }}
+ path: dist
+ retention-days: 1
+
+ test:
+ runs-on: ${{ matrix.os }}
+ needs: build
+ strategy:
+ matrix:
+ os: [ ubuntu-latest, macos-latest, windows-latest ]
+ node: ["18", "20", "22"]
+ fail-fast: false
+ name: Test Node ${{ matrix.node }} (${{ matrix.os }})
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ - name: Setup node
+ uses: actions/setup-node@v3
+ with:
+ node-version: ${{ matrix.node }}
+ check-latest: true
+ - name: node_modules cache
+ id: node_modules_cache
+ uses: actions/cache@v3
+ with:
+ path: ./node_modules
+ key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-${{ matrix.node }}-
+ - name: Install deps
+ if: steps.node_modules_cache.outputs.cache-hit != 'true'
+ run: npm ci
+ - name: Download Artifacts
+ uses: actions/download-artifact@v4
+ - name: Relocate Artifacts
+ run: mv angularfire-${{ github.run_id }} dist
+ - name: Test Node
+ run: |
+ npm run build:jasmine
+ npm run test:node
+
+ browser:
+ runs-on: ${{ matrix.os }}
+ needs: build
+ name: Test ${{ matrix.browser }}
+ strategy:
+ matrix:
+ os: [ ubuntu-latest ]
+ browser: [ chrome-headless, firefox-headless ]
+ # TODO(davideast): Figure out why Safari tests timeout only on CI
+ # include:
+ # - os: macos-latest
+ # browser: safari
+ fail-fast: false
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ - name: Setup node
+ uses: actions/setup-node@v3
+ with:
+ node-version: 20
+ check-latest: false
+ - name: Setup java
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'temurin'
+ java-version: '11'
+ - name: node_modules cache
+ id: node_modules_cache
+ uses: actions/cache@v3
+ with:
+ path: ./node_modules
+ key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-${{ matrix.node }}-
+ - name: Install deps
+ if: steps.node_modules_cache.outputs.cache-hit != 'true'
+ run: npm ci
+ - name: Firebase emulator cache
+ uses: actions/cache@v3
+ with:
+ path: ~/.cache/firebase/emulators
+ key: firebase_emulators
+ - name: Download Artifacts
+ uses: actions/download-artifact@v4
+ - name: Relocate Artifacts
+ run: mv angularfire-${{ github.run_id }} dist
+ - name: Test browser
+ run: npm run test:${{ matrix.browser }}
+
+ contribute:
+ runs-on: ${{ matrix.os }}
+ name: Contribute Node ${{ matrix.node }} (${{ matrix.os }})
+ strategy:
+ matrix:
+ os: [ ubuntu-latest, macos-latest, windows-latest ]
+ node: ["20"]
+ fail-fast: false
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ - name: Setup node
+ uses: actions/setup-node@v3
+ with:
+ node-version: ${{ matrix.node }}
+ check-latest: true
+ - name: node_modules cache
+ uses: actions/cache@v3
+ id: node_modules_cache
+ with:
+ path: ./node_modules
+ key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-${{ matrix.node }}-
+ - name: Install deps
+ if: steps.node_modules_cache.outputs.cache-hit != 'true'
+ run: npm ci
+ #- name: Lint
+ # run: npm run lint
+ - name: Build
+ run: npm run build
+ - name: Test Node
+ run: |
+ npm run build:jasmine
+ npm run test:node
+ - name: Firebase emulator cache
+ uses: actions/cache@v3
+ with:
+ path: ~/.cache/firebase/emulators
+ key: firebase_emulators
+ - name: Setup java
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'temurin'
+ java-version: '11'
+ - name: Test headless
+ run: npm run test:chrome-headless
+ # Tests are flaky on Windows
+ continue-on-error: ${{ matrix.os == 'windows-latest' }}
+
+ # Break the branch protection test into a seperate step, so we can manage the matrix more easily
+ test_and_contribute:
+ runs-on: ubuntu-latest
+ name: Branch protection
+ needs: ['test', 'contribute', 'browser']
+ steps:
+ - run: true
+
+ publish:
+ runs-on: ubuntu-latest
+ name: Publish (NPM)
+ needs: ['build', 'test', 'browser']
+ if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
+ steps:
+ - name: Setup node
+ uses: actions/setup-node@v3
+ with:
+ node-version: '20'
+ registry-url: 'https://registry.npmjs.org/'
+ check-latest: false
+ - name: 'Download Artifacts'
+ uses: actions/download-artifact@v4
+ - name: Publish
+ run: |
+ cd ./angularfire-${{ github.run_id }}/packages-dist
+ chmod +x publish.sh
+ ./publish.sh
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/.gitignore b/.gitignore
index db6aa54b0..beb5d455e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,12 +1,27 @@
node_modules/
dist/
+dist-test/
docs/api/
typings/
npm-debug.log
.idea/
-test/e2e/firebase_list/firebase_list_example.js
-test/e2e/firebase_list/firebase_list_example.js.map
-test/e2e/firebase_list/firebase_list_example.d.ts
-test/e2e/firebase_object/firebase_object_example.js
-test/e2e/firebase_object/firebase_object_example.js.map
-test/e2e/firebase_object/firebase_object_example.d.ts
+.vscode/settings.json
+angular-fire-*.tgz
+angularfire2-*.tgz
+*.ngfactory.ts
+*.ngsummary.json
+.DS_Store
+yarn-error.log
+*.bak
+yarn.lock
+test/ng-build/**/yarn.lock
+tools/build.js
+coverage
+*.log
+api-*.json
+angularfire.tgz
+unpack.sh
+publish.sh
+.firebase
+.angular
+.vscode
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
index 77923cf1e..02a57a315 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,2 +1,7 @@
*.spec.*
-
+test-config.*
+publish.sh
+__ivy_ngcc__/
+*.min.js
+*.min.js.map
+*.__ivy_ngcc_bak
\ No newline at end of file
diff --git a/.nvmrc b/.nvmrc
new file mode 100644
index 000000000..1a2f5bd20
--- /dev/null
+++ b/.nvmrc
@@ -0,0 +1 @@
+lts/*
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 099665c29..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-language: node_js
-sudo: false
-node_js:
-- '5.4.1'
-
-addons:
- firefox: latest
- apt:
- sources:
- - ubuntu-toolchain-r-test
- packages:
- - g++-4.8
- hosts:
- - localhost.firebaseio.test
-
-cache:
- directories:
- - node_modules
- - typings
-
-env:
- - CXX=g++-4.8
-
-install:
- - npm install
-
-before_script:
- - export DISPLAY=:99.0
- - sh -e /etc/init.d/xvfb start
-
-script:
- - npm run build
- - ./node_modules/.bin/karma start --single-run --browsers Firefox
- # Can't run until https://github.com/angular/protractor/issues/2784 is resolved
- #- ./node_modules/.bin/protractor protractor.conf.js --browser firefox
-
-notifications:
- webhooks:
- on_success: always # options: [always|never|change] default: always
- on_failure: always # options: [always|never|change] default: always
- on_start: false # default: false
diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index 22da00bf5..000000000
--- a/CHANGELOG.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# AngularFire2 2.0.0-beta.0
-
-## Features
- * Declarative Querying [Commit](https://github.com/angular/angularfire2/commit/62c16078488e7320c91baeec6b9b255469a34cc9)
- * Upgrade to Angular RC.1 [Commit](https://github.com/angular/angularfire2/commit/1eb383aa7e4855996101b07356db31476ca29ef9)
-
-## Bug Fixes
- * **FirebaseListFactory**: prevent first item being duplicated when it [Commit](https://github.com/angular/angularfire2/commit/314c5954215cf5e6a9129ac973dee1831268d6a5)
-
-
-## Docs
- * Many Developer guides added! [First Guide](https://github.com/angular/angularfire2/blob/master/docs/1-install-and-setup.md) [Commit](https://github.com/angular/angularfire2/commit/d1ac3a483c3d334f10e929e299e4e75e3395af31)
-
-## Breaking Changes:
- * Web Worker support has been temporarily removed due to Angular 2 RC.0 not yet supporting Web Workers
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..80c804e2a
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,163 @@
+# Contributing to AngularFire
+
+We would love for you to contribute to AngularFire and help make it even better than it is
+today! As a contributor, here are the guidelines we would like you to follow:
+
+ - [Code of Conduct](#coc)
+ - [Question or Problem?](#question)
+ - [Issues and Bugs](#issue)
+ - [Feature Requests](#feature)
+ - [Initial Setup](#setup)
+ - [Submission Guidelines](#submit)
+ - [Submitting an Issue](#submit-issue)
+ - [Submitting a Pull Request](#submit-pr)
+ - [Before you submit](#submit-before)
+ - [How to submit](#submit-how)
+ - [Deploying docs](#submit-docs)
+ - Appendix
+ - [Coding Rules][rules] (external link)
+ - [Commit Message Guidelines][commit] (external link)
+ - [Signing the CLA](#cla)
+
+## Code of Conduct
+
+Help us keep the Angular and Firebase communities open and inclusive. Please read and follow the Angular [Code of Conduct][coc].
+
+## Got a Question or Problem?
+
+If you have questions about how to *use* AngularFire, please direct them to the [Angular Google Group][angular-group]
+discussion list or [StackOverflow][stackoverflow] (include the `firebase` and `angular` tags!).
+Please note that the Angular team's capacity to answer usage questions is limited.
+Members of the Firebase team can be reached on [Slack][slack] and via the [Firebase Google Group][firebase-group].
+
+## Found an Issue?
+
+If you find a bug in the source code, you can help us by
+[submitting an issue](#submit-issue) to our [GitHub Repository][github]. Even better, you can
+[submit a Pull Request](#submit-pr) with a fix.
+
+## Want a Feature?
+
+You can *request* a new feature by [submitting an issue](#submit-issue) to our [GitHub
+Repository][github]. If you would like to *implement* a new feature, please submit an issue with
+a proposal for your work first, to be sure that we can use it.
+Please consider what kind of change it is:
+
+* For a **Major Feature**, first open an issue and outline your proposal so that it can be
+discussed. This will also allow us to better coordinate our efforts, prevent duplication of work,
+and help you to craft the change so that it is successfully accepted into the project.
+* **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr).
+
+## Initial Setup
+
+1) Create a fork of AngularFire (See [Forking a Project][github-fork])
+
+2) Clone your fork, CD into the directory, and install dependencies
+
+```shell
+$ git clone
- The official library for Firebase and Angular 2AngularFire2
-
ng add @angular/fire-## What is AngularFire2? +- **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. -- **Observable based** - Use the power of rxjs, Angular 2, and Firebase. -- **Realtime bindings** - Synchronize collections as objects or lists. -- **Authentication** - Monitor authentication state in realtime. +## Example use -## Install +```ts +import { provideFirebaseApp, initializeApp } from '@angular/fire/app'; +import { getFirestore, provideFirestore } from '@angular/fire/firestore'; -```bash -npm install angularfire2 firebase --save +export const appConfig: ApplicationConfig = { + providers: [ + provideFirebaseApp(() => initializeApp({ ... })), + provideFirestore(() => getFirestore()), + ... + ], + ... +}) ``` -## Example use: - ```ts -import {Component} from '@angular/core'; -import {AngularFire, FirebaseListObservable} from 'angularfire2'; +import { AsyncPipe } from '@angular/common'; +import { inject } from '@angular/core'; +import { Firestore, collectionData, collection } from '@angular/fire/firestore'; + +interface Item { + name: string, + ... +}; @Component({ - selector: 'project-name-app', + selector: 'app-root', template: `
| + +#### [Analytics](docs/analytics.md#analytics) +```ts +import { } from '@angular/fire/analytics'; +``` + | ++ +#### [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'; +``` + | +
| + +#### [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'; +``` + | ++ +#### [App Check](docs/app-check.md#app-check) +```ts +import { } from '@angular/fire/app-check'; +``` + | +
| + +#### [Vertex AI](docs/vertexai.md#vertex-ai) +```ts +import { } from '@angular/fire/vertexai'; +``` + | -## [API Reference](docs/api-reference.md) +
+
+
+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 a 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/api-reference.md b/docs/api-reference.md
deleted file mode 100644
index bdb0003b9..000000000
--- a/docs/api-reference.md
+++ /dev/null
@@ -1,220 +0,0 @@
-#API Reference
-
-**Work in progress. [See the developer guide](/docs/1-install-and-setup.md) for a comprehensive walkthrough of AngularFire2.**
-
-### AngularFire Service
-
-The recommended way to take advantage of the AngularFire library is to
-use the injectable AngularFire service.
-
-```typescript
-import {Component} from '@angular/core';
-import {bootstrap} from '@angular2/platform-browser';
-import {Observable} from 'rxjs/Observable';
-import {FIREBASE_PROVIDERS, defaultFirebase, AngularFire} from 'angularfire2';
-import {Question} from './services/question';
-
-@Component({
- template:`
-
+
+# 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 a App Check instance in the application's `app.config.ts`:
+
+```ts
+import { provideFirebaseApp, initializeApp } 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-enterprise-provider) | [API Reference](https://firebase.google.com/docs/reference/js/app-check)
diff --git a/docs/auth.md b/docs/auth.md
new file mode 100644
index 000000000..8ce5a51aa
--- /dev/null
+++ b/docs/auth.md
@@ -0,0 +1,200 @@
+
+
+
+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 a Auth instance in the application's `app.config.ts`:
+
+```ts
+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(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(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(auth);
+ idTokenSubscription: Subscription;
+ ...
+
+ constructor() {
+ this.idTokenSubscription = this.idToken$.subscribe((token: string | null) => {
+ //handle idToken changes here. Note, that user will be null if there is no currently logged in user.
+ console.log(string);
+ })
+ }
+
+ ngOnDestroy() {
+ // when manually subscribing to an observable remember to unsubscribe in ngOnDestroy
+ this.idTokenSubscription.unsubscribe();
+ }
+}
+```
+
+## Connecting the emulator suite
+
+```ts
+import { connectAuthEmulator, getAuth, provideAuth } from '@angular/fire/auth';
+
+@NgModule({
+ imports: [
+ 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..ddd89f3b0
--- /dev/null
+++ b/docs/compat.md
@@ -0,0 +1,70 @@
+# AngularFire
+The official [Angular](https://angular.io/) 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 { 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 { 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 `