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.
- package/README.md +113 -45
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,64 +1,132 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ngx-firebase
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A lightweight, drop-in, and zoneless-friendly wrapper around the native **Firebase JS SDK** for **Angular 22+**.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
ng generate component component-name
|
|
11
|
-
```
|
|
9
|
+
## ⚡ Features
|
|
12
10
|
|
|
13
|
-
|
|
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
|
-
|
|
16
|
-
ng generate --help
|
|
17
|
-
```
|
|
17
|
+
---
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## 📦 Installation
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Install both the library and the native Firebase SDK:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
npm install ngx-firebase firebase
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
57
|
-
|
|
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
|
-
|
|
128
|
+
---
|
|
61
129
|
|
|
62
|
-
##
|
|
130
|
+
## 📄 License
|
|
63
131
|
|
|
64
|
-
|
|
132
|
+
MIT © 2026 Sebas (quedicesebas)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-firebase",
|
|
3
|
-
"version": "22.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
|
},
|