ngx-firebase 22.0.0 → 22.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +113 -45
  2. package/package.json +1 -2
package/README.md CHANGED
@@ -1,64 +1,132 @@
1
- # NgxFirebase
1
+ # @ngx-firebase
2
2
 
3
- This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 22.0.0.
3
+ A lightweight, drop-in, and zoneless-friendly wrapper around the native **Firebase JS SDK** for **Angular 22+**.
4
4
 
5
- ## Code scaffolding
5
+ This library serves as a modern, boilerplate-free alternative to `@angular/fire`, providing native Angular Dependency Injection (DI) class tokens and reactive RxJS wrappers around standard Firebase listeners.
6
6
 
7
- Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
7
+ ---
8
8
 
9
- ```bash
10
- ng generate component component-name
11
- ```
9
+ ## ⚡ Features
12
10
 
13
- For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
11
+ - 📦 **Zero overhead**: Communicates directly with the Firebase JS SDK without complex wrappers.
12
+ - 💉 **Native Angular DI**: Standard provider functions (`provideFirestore`, `provideAuth`, etc.) compatible with Angular's `ApplicationConfig`.
13
+ - 🎭 **RxJS Wrappers**: Lightweight, memory-leak-safe wrappers for common tasks (`docData`, `collectionSnapshots`, `user`).
14
+ - ⏱️ **Zoneless Friendly**: Uses native SDK snapshot listeners wrapped in RxJS observable streams.
15
+ - 📊 **Screen Tracking**: Custom built-in `ScreenTrackingService` for automated Google Analytics route tracking.
14
16
 
15
- ```bash
16
- ng generate --help
17
- ```
17
+ ---
18
18
 
19
- ## Building
19
+ ## 📦 Installation
20
20
 
21
- To build the library, run:
21
+ Install both the library and the native Firebase SDK:
22
22
 
23
23
  ```bash
24
- ng build ngx-firebase
24
+ npm install ngx-firebase firebase
25
25
  ```
26
26
 
27
- This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28
-
29
- ### Publishing the Library
30
-
31
- Once the project is built, you can publish your library by following these steps:
32
-
33
- 1. Navigate to the `dist` directory:
34
-
35
- ```bash
36
- cd dist/ngx-firebase
37
- ```
38
-
39
- 2. Run the `npm publish` command to publish your library to the npm registry:
40
- ```bash
41
- npm publish
42
- ```
43
-
44
- ## Running unit tests
45
-
46
- To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
47
-
48
- ```bash
49
- ng test
27
+ ---
28
+
29
+ ## 🚀 Quick Start
30
+
31
+ ### 1. Configure Providers
32
+
33
+ Register the Firebase services in your `app.config.ts` using the functional providers:
34
+
35
+ ```typescript
36
+ import { ApplicationConfig } from '@angular/core';
37
+ import { provideRouter } from '@angular/router';
38
+ import { initializeApp } from 'firebase/app';
39
+ import { getAuth } from 'firebase/auth';
40
+ import { getFirestore } from 'firebase/firestore';
41
+ import {
42
+ provideFirebaseApp,
43
+ provideAuth,
44
+ provideFirestore
45
+ } from 'ngx-firebase';
46
+
47
+ import { routes } from './app.routes';
48
+
49
+ export const appConfig: ApplicationConfig = {
50
+ providers: [
51
+ provideRouter(routes),
52
+
53
+ // Initialize Firebase App
54
+ provideFirebaseApp(() => initializeApp({
55
+ apiKey: "YOUR_API_KEY",
56
+ authDomain: "YOUR_AUTH_DOMAIN",
57
+ projectId: "YOUR_PROJECT_ID",
58
+ storageBucket: "YOUR_STORAGE_BUCKET",
59
+ messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
60
+ appId: "YOUR_APP_ID",
61
+ measurementId: "YOUR_MEASUREMENT_ID"
62
+ })),
63
+
64
+ // Provide Firestore & Auth
65
+ provideFirestore(() => getFirestore()),
66
+ provideAuth(() => getAuth())
67
+ ]
68
+ };
50
69
  ```
51
70
 
52
- ## Running end-to-end tests
53
-
54
- For end-to-end (e2e) testing, run:
71
+ ### 2. Using Services in Standalone Components
72
+
73
+ Inject the native Firebase instances directly using the provided tokens, and use the RxJS helpers:
74
+
75
+ ```typescript
76
+ import { Component, inject } from '@angular/core';
77
+ import { CommonModule } from '@angular/common';
78
+ import { Firestore, doc } from 'firebase/firestore';
79
+ import { docData } from 'ngx-firebase';
80
+ import { Observable } from 'rxjs';
81
+
82
+ @Component({
83
+ selector: 'app-store-detail',
84
+ standalone: true,
85
+ imports: [CommonModule],
86
+ template: `
87
+ <div *ngIf="store$ | async as store">
88
+ <h1>{{ store.name }}</h1>
89
+ <p>{{ store.description }}</p>
90
+ </div>
91
+ `
92
+ })
93
+ export class StoreDetailComponent {
94
+ private firestore = inject(Firestore);
95
+ store$: Observable<any>;
96
+
97
+ constructor() {
98
+ // Reference a document using the native Firestore SDK
99
+ const storeRef = doc(this.firestore, 'stores/store_123');
100
+
101
+ // Wrap it reactively using docData
102
+ this.store$ = docData(storeRef);
103
+ }
104
+ }
105
+ ```
55
106
 
56
- ```bash
57
- ng e2e
107
+ ### 3. Track Route Page Views Automatically (Google Analytics)
108
+
109
+ To enable automatic page view tracking, register `provideAnalytics` and inject `ScreenTrackingService` in your client config:
110
+
111
+ ```typescript
112
+ import { ApplicationConfig, provideEnvironmentInitializer, inject } from '@angular/core';
113
+ import { getAnalytics } from 'firebase/analytics';
114
+ import { provideAnalytics, ScreenTrackingService } from 'ngx-firebase';
115
+
116
+ export const clientConfig: ApplicationConfig = {
117
+ providers: [
118
+ provideAnalytics(() => getAnalytics()),
119
+ ScreenTrackingService,
120
+ provideEnvironmentInitializer(() => {
121
+ // Force service initialization to listen to router events
122
+ inject(ScreenTrackingService);
123
+ })
124
+ ]
125
+ };
58
126
  ```
59
127
 
60
- Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
128
+ ---
61
129
 
62
- ## Additional Resources
130
+ ## 📄 License
63
131
 
64
- For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
132
+ MIT © 2026 Sebas (quedicesebas)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-firebase",
3
- "version": "22.0.0",
3
+ "version": "22.0.1",
4
4
  "description": "A lightweight, drop-in, and zoneless-friendly wrapper around the native Firebase JS SDK for Angular 22+.",
5
5
  "keywords": [
6
6
  "angular",
@@ -21,7 +21,6 @@
21
21
  "url": "git+https://github.com/quedicesebas/ngx-firebase.git"
22
22
  },
23
23
  "license": "MIT",
24
- "author": "Sebas <quedicesebas>",
25
24
  "publishConfig": {
26
25
  "access": "public"
27
26
  },