@angular/fire 20.1.0 → 21.0.0-canary.20260927232311.sha-38dfc3f
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 +41 -32
- package/ai/package.json +2 -1
- package/analytics/package.json +2 -1
- package/app/package.json +2 -1
- package/app-check/package.json +2 -1
- package/auth/package.json +2 -1
- package/auth-guard/package.json +2 -1
- package/compat/analytics/package.json +2 -1
- package/compat/auth/package.json +2 -1
- package/compat/auth-guard/package.json +2 -1
- package/compat/database/package.json +2 -1
- package/compat/firestore/package.json +2 -1
- package/compat/functions/package.json +2 -1
- package/compat/messaging/package.json +2 -1
- package/compat/package.json +2 -1
- package/compat/performance/package.json +2 -1
- package/compat/remote-config/package.json +2 -1
- package/compat/storage/package.json +2 -1
- package/data-connect/package.json +2 -1
- package/database/package.json +2 -1
- package/docs/ai.md +52 -0
- package/docs/analytics.md +2 -5
- package/docs/app-check.md +6 -8
- package/docs/app-hosting.md +95 -0
- package/docs/auth.md +214 -29
- package/docs/compat/auth/router-guards.md +1 -1
- package/docs/compat.md +1 -1
- package/docs/data-connect.md +56 -0
- package/docs/database.md +14 -12
- package/docs/deploy/getting-started.md +2 -0
- package/docs/firestore.md +7 -7
- package/docs/functions.md +3 -5
- package/docs/install-and-setup.md +45 -24
- package/docs/install-firebase-tools.md +2 -0
- package/docs/messaging.md +83 -52
- package/docs/performance.md +3 -5
- package/docs/remote-config.md +3 -5
- package/docs/storage.md +3 -5
- package/docs/version-21-upgrade.md +90 -0
- package/docs/zones.md +45 -1
- package/fesm2022/angular-fire-ai.mjs +8 -8
- package/fesm2022/angular-fire-ai.mjs.map +1 -1
- package/fesm2022/angular-fire-analytics.mjs +10 -10
- package/fesm2022/angular-fire-analytics.mjs.map +1 -1
- package/fesm2022/angular-fire-app-check.mjs +4 -4
- package/fesm2022/angular-fire-app-check.mjs.map +1 -1
- package/fesm2022/angular-fire-app.mjs +5 -6
- package/fesm2022/angular-fire-app.mjs.map +1 -1
- package/fesm2022/angular-fire-auth-guard.mjs +7 -7
- package/fesm2022/angular-fire-auth-guard.mjs.map +1 -1
- package/fesm2022/angular-fire-auth.mjs +4 -4
- package/fesm2022/angular-fire-auth.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-analytics.mjs +17 -21
- package/fesm2022/angular-fire-compat-analytics.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-auth-guard.mjs +7 -7
- package/fesm2022/angular-fire-compat-auth-guard.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-auth.mjs +9 -11
- package/fesm2022/angular-fire-compat-auth.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-database.mjs +11 -13
- package/fesm2022/angular-fire-compat-database.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-firestore.mjs +12 -14
- package/fesm2022/angular-fire-compat-firestore.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-functions.mjs +7 -7
- package/fesm2022/angular-fire-compat-functions.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-messaging.mjs +9 -11
- package/fesm2022/angular-fire-compat-messaging.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-performance.mjs +13 -17
- package/fesm2022/angular-fire-compat-performance.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-remote-config.mjs +11 -16
- package/fesm2022/angular-fire-compat-remote-config.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-storage.mjs +16 -18
- package/fesm2022/angular-fire-compat-storage.mjs.map +1 -1
- package/fesm2022/angular-fire-compat.mjs +8 -9
- package/fesm2022/angular-fire-compat.mjs.map +1 -1
- package/fesm2022/angular-fire-data-connect.mjs +4 -4
- package/fesm2022/angular-fire-data-connect.mjs.map +1 -1
- package/fesm2022/angular-fire-database.mjs +4 -4
- package/fesm2022/angular-fire-database.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore-lite.mjs +4 -4
- package/fesm2022/angular-fire-firestore-lite.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore.mjs +9 -6
- package/fesm2022/angular-fire-firestore.mjs.map +1 -1
- package/fesm2022/angular-fire-functions.mjs +4 -4
- package/fesm2022/angular-fire-functions.mjs.map +1 -1
- package/fesm2022/angular-fire-messaging.mjs +10 -6
- package/fesm2022/angular-fire-messaging.mjs.map +1 -1
- package/fesm2022/angular-fire-performance.mjs +5 -8
- package/fesm2022/angular-fire-performance.mjs.map +1 -1
- package/fesm2022/angular-fire-remote-config.mjs +7 -6
- package/fesm2022/angular-fire-remote-config.mjs.map +1 -1
- package/fesm2022/angular-fire-storage.mjs +4 -4
- package/fesm2022/angular-fire-storage.mjs.map +1 -1
- package/fesm2022/angular-fire.mjs +4 -6
- package/fesm2022/angular-fire.mjs.map +1 -1
- package/firestore/lite/package.json +2 -1
- package/firestore/package.json +2 -1
- package/functions/package.json +2 -1
- package/messaging/package.json +2 -1
- package/package.json +73 -69
- package/performance/package.json +2 -1
- package/publish.sh +1 -1
- package/remote-config/package.json +2 -1
- package/schematics/add/index.js +1 -1
- package/schematics/deploy/actions.js +76 -85
- package/schematics/deploy/builder.js +161 -170
- package/schematics/deploy/schema.json +6 -3
- package/schematics/migration.json +4 -4
- package/schematics/setup/index.js +174 -172
- package/schematics/update/v21/index.js +1 -0
- package/schematics/update/v7/index.js +1 -1
- package/storage/package.json +2 -1
- package/{ai/index.d.ts → types/angular-fire-ai.d.ts} +4 -4
- package/{app/index.d.ts → types/angular-fire-app.d.ts} +1 -1
- package/{auth-guard/index.d.ts → types/angular-fire-auth-guard.d.ts} +2 -2
- package/{compat/analytics/index.d.ts → types/angular-fire-compat-analytics.d.ts} +2 -2
- package/{compat/auth-guard/index.d.ts → types/angular-fire-compat-auth-guard.d.ts} +2 -2
- package/{compat/auth/index.d.ts → types/angular-fire-compat-auth.d.ts} +1 -1
- package/{compat/database/index.d.ts → types/angular-fire-compat-database.d.ts} +5 -6
- package/{compat/firestore/index.d.ts → types/angular-fire-compat-firestore.d.ts} +5 -11
- package/{compat/functions/index.d.ts → types/angular-fire-compat-functions.d.ts} +1 -1
- package/{compat/messaging/index.d.ts → types/angular-fire-compat-messaging.d.ts} +2 -2
- package/{compat/performance/index.d.ts → types/angular-fire-compat-performance.d.ts} +2 -2
- package/{compat/remote-config/index.d.ts → types/angular-fire-compat-remote-config.d.ts} +3 -3
- package/{compat/storage/index.d.ts → types/angular-fire-compat-storage.d.ts} +18 -18
- package/{compat/index.d.ts → types/angular-fire-compat.d.ts} +2 -2
- package/{firestore/lite/index.d.ts → types/angular-fire-firestore-lite.d.ts} +1 -1
- package/{firestore/index.d.ts → types/angular-fire-firestore.d.ts} +6 -3
- package/{messaging/index.d.ts → types/angular-fire-messaging.d.ts} +6 -2
- package/{remote-config/index.d.ts → types/angular-fire-remote-config.d.ts} +3 -2
- package/docs/firebase.json +0 -16
- package/docs/install-angular-cli-windows10.md +0 -82
- package/docs/vertexai.md +0 -53
- package/fesm2022/angular-fire-vertexai.mjs +0 -102
- package/fesm2022/angular-fire-vertexai.mjs.map +0 -1
- package/schematics/update/index.js +0 -1
- package/vertexai/index.d.ts +0 -33
- package/vertexai/package.json +0 -3
- /package/{analytics/index.d.ts → types/angular-fire-analytics.d.ts} +0 -0
- /package/{app-check/index.d.ts → types/angular-fire-app-check.d.ts} +0 -0
- /package/{auth/index.d.ts → types/angular-fire-auth.d.ts} +0 -0
- /package/{data-connect/index.d.ts → types/angular-fire-data-connect.d.ts} +0 -0
- /package/{database/index.d.ts → types/angular-fire-database.d.ts} +0 -0
- /package/{functions/index.d.ts → types/angular-fire-functions.d.ts} +0 -0
- /package/{performance/index.d.ts → types/angular-fire-performance.d.ts} +0 -0
- /package/{storage/index.d.ts → types/angular-fire-storage.d.ts} +0 -0
- /package/{index.d.ts → types/angular-fire.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -5,48 +5,47 @@ AngularFire smooths over the rough edges an Angular developer might encounter wh
|
|
|
5
5
|
[Firebase JS SDK](https://github.com/firebase/firebase-js-sdk) & aims to provide a more natural developer experience
|
|
6
6
|
by conforming to Angular conventions.
|
|
7
7
|
|
|
8
|
-
<strong><pre>ng add @angular/fire</pre></strong>
|
|
8
|
+
<strong><pre>ng add @angular/fire@next</pre></strong>
|
|
9
9
|
|
|
10
10
|
- **Dependency injection** - Provide and Inject Firebase services in your components.
|
|
11
11
|
- **Zone.js wrappers** - Stable zones allow proper functionality of service workers, forms, SSR, and pre-rendering.
|
|
12
12
|
- **Observable based** - Utilize RxJS rather than callbacks for real-time streams.
|
|
13
13
|
- **NgRx friendly API** - Integrate with NgRx using AngularFire's action based APIs.
|
|
14
14
|
- **Lazy-loading** - AngularFire dynamically imports much of Firebase, reducing the time to load your app.
|
|
15
|
-
- **Deploy schematics** - Get your Angular application deployed on Firebase Hosting with a single command.
|
|
16
15
|
- **Google Analytics** - Zero-effort Angular Router awareness in Google Analytics.
|
|
17
16
|
- **Router Guards** - Guard your Angular routes with built-in Firebase Authentication checks.
|
|
18
17
|
|
|
19
18
|
## Example use
|
|
20
19
|
|
|
21
20
|
```ts
|
|
21
|
+
import { ApplicationConfig } from '@angular/core';
|
|
22
22
|
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
23
23
|
import { getFirestore, provideFirestore } from '@angular/fire/firestore';
|
|
24
24
|
|
|
25
25
|
export const appConfig: ApplicationConfig = {
|
|
26
26
|
providers: [
|
|
27
|
-
provideFirebaseApp(() => initializeApp({ ... })),
|
|
27
|
+
provideFirebaseApp(() => initializeApp({ /* ...your Firebase config... */ })),
|
|
28
28
|
provideFirestore(() => getFirestore()),
|
|
29
|
-
...
|
|
29
|
+
// ...
|
|
30
30
|
],
|
|
31
|
-
...
|
|
32
|
-
}
|
|
31
|
+
// ...
|
|
32
|
+
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
36
|
import { AsyncPipe } from '@angular/common';
|
|
37
|
-
import { inject } from '@angular/core';
|
|
37
|
+
import { Component, inject } from '@angular/core';
|
|
38
38
|
import { Firestore, collectionData, collection } from '@angular/fire/firestore';
|
|
39
39
|
|
|
40
40
|
interface Item {
|
|
41
|
-
name: string
|
|
42
|
-
...
|
|
41
|
+
name: string;
|
|
43
42
|
};
|
|
44
43
|
|
|
45
44
|
@Component({
|
|
46
45
|
selector: 'app-root',
|
|
47
46
|
template: `
|
|
48
47
|
<ul>
|
|
49
|
-
@for (item of (
|
|
48
|
+
@for (item of (items$ | async); track item) {
|
|
50
49
|
<li>
|
|
51
50
|
{{ item.name }}
|
|
52
51
|
</li>
|
|
@@ -55,10 +54,10 @@ interface Item {
|
|
|
55
54
|
`,
|
|
56
55
|
imports: [AsyncPipe]
|
|
57
56
|
})
|
|
58
|
-
export class
|
|
57
|
+
export class App {
|
|
59
58
|
firestore = inject(Firestore);
|
|
60
59
|
itemCollection = collection(this.firestore, 'items');
|
|
61
|
-
|
|
60
|
+
items$ = collectionData<Item>(this.itemCollection);
|
|
62
61
|
}
|
|
63
62
|
```
|
|
64
63
|
|
|
@@ -66,12 +65,16 @@ export class AppComponent {
|
|
|
66
65
|
|
|
67
66
|
[Quickstart](docs/install-and-setup.md) - Get your first application up and running by following our quickstart guide.
|
|
68
67
|
|
|
68
|
+
[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.
|
|
69
|
+
|
|
69
70
|
[Contributing](CONTRIBUTING.md)
|
|
70
71
|
|
|
71
|
-
[Stackblitz Template](https://stackblitz.com/edit/angular-fire-start) -
|
|
72
|
+
[Stackblitz Template](https://stackblitz.com/edit/angular-fire-start) - A runnable AngularFire example. Add your own Firebase configuration to connect it to your project.
|
|
72
73
|
|
|
73
74
|
[Upgrading from v6.0? Check out our guide.](docs/version-7-upgrade.md)
|
|
74
75
|
|
|
76
|
+
[Upgrading from AngularFire 20? See the v21 upgrade guide.](docs/version-21-upgrade.md)
|
|
77
|
+
|
|
75
78
|
### Sample app
|
|
76
79
|
|
|
77
80
|
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.
|
|
@@ -80,7 +83,7 @@ The [`sample`](sample) folder contains a kitchen sink application that demonstra
|
|
|
80
83
|
|
|
81
84
|
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).
|
|
82
85
|
|
|
83
|
-
> **NOTE:**
|
|
86
|
+
> **NOTE:** Questions on the mailing list and issues filed here are answered on a <strong>best-effort basis</strong> by maintainers and other community members. If you are able to reproduce a problem with Firebase <em>outside of AngularFire's implementation</em>, 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/).
|
|
84
87
|
|
|
85
88
|
## Developer Guide
|
|
86
89
|
|
|
@@ -94,10 +97,26 @@ This developer guide assumes you're using the new tree-shakable AngularFire API,
|
|
|
94
97
|
<tr>
|
|
95
98
|
<td>
|
|
96
99
|
|
|
100
|
+
#### [AI Logic](docs/ai.md#ai-logic)
|
|
101
|
+
```ts
|
|
102
|
+
import { } from '@angular/fire/ai';
|
|
103
|
+
```
|
|
104
|
+
</td>
|
|
105
|
+
<td>
|
|
106
|
+
|
|
97
107
|
#### [Analytics](docs/analytics.md#analytics)
|
|
98
108
|
```ts
|
|
99
109
|
import { } from '@angular/fire/analytics';
|
|
100
110
|
```
|
|
111
|
+
</td>
|
|
112
|
+
</tr>
|
|
113
|
+
<tr>
|
|
114
|
+
<td>
|
|
115
|
+
|
|
116
|
+
#### [App Check](docs/app-check.md#app-check)
|
|
117
|
+
```ts
|
|
118
|
+
import { } from '@angular/fire/app-check';
|
|
119
|
+
```
|
|
101
120
|
</td>
|
|
102
121
|
<td>
|
|
103
122
|
|
|
@@ -142,43 +161,33 @@ import { } from '@angular/fire/storage';
|
|
|
142
161
|
<tr>
|
|
143
162
|
<td>
|
|
144
163
|
|
|
145
|
-
#### [
|
|
164
|
+
#### [Data Connect](docs/data-connect.md#data-connect)
|
|
146
165
|
```ts
|
|
147
|
-
import { } from '@angular/fire/
|
|
166
|
+
import { } from '@angular/fire/data-connect';
|
|
148
167
|
```
|
|
149
168
|
</td>
|
|
150
169
|
<td>
|
|
151
170
|
|
|
152
|
-
#### [
|
|
171
|
+
#### [Performance Monitoring](docs/performance.md#performance-monitoring)
|
|
153
172
|
```ts
|
|
154
|
-
import { } from '@angular/fire/
|
|
173
|
+
import { } from '@angular/fire/performance';
|
|
155
174
|
```
|
|
156
175
|
</td>
|
|
157
176
|
</tr>
|
|
158
177
|
<tr>
|
|
159
178
|
<td>
|
|
160
179
|
|
|
161
|
-
#### [
|
|
162
|
-
```ts
|
|
163
|
-
import { } from '@angular/fire/remote-config';
|
|
164
|
-
```
|
|
165
|
-
</td>
|
|
166
|
-
<td>
|
|
167
|
-
|
|
168
|
-
#### [App Check](docs/app-check.md#app-check)
|
|
180
|
+
#### [Realtime Database](docs/database.md#realtime-database)
|
|
169
181
|
```ts
|
|
170
|
-
import { } from '@angular/fire/
|
|
182
|
+
import { } from '@angular/fire/database';
|
|
171
183
|
```
|
|
172
184
|
</td>
|
|
173
|
-
</tr>
|
|
174
|
-
<tr>
|
|
175
185
|
<td>
|
|
176
186
|
|
|
177
|
-
#### [
|
|
187
|
+
#### [Remote Config](docs/remote-config.md#remote-config)
|
|
178
188
|
```ts
|
|
179
|
-
import { } from '@angular/fire/
|
|
189
|
+
import { } from '@angular/fire/remote-config';
|
|
180
190
|
```
|
|
181
191
|
</td>
|
|
182
|
-
|
|
183
192
|
</tr>
|
|
184
193
|
</table>
|
package/ai/package.json
CHANGED
package/analytics/package.json
CHANGED
package/app/package.json
CHANGED
package/app-check/package.json
CHANGED
package/auth/package.json
CHANGED
package/auth-guard/package.json
CHANGED
package/compat/auth/package.json
CHANGED
package/compat/package.json
CHANGED
package/database/package.json
CHANGED
package/docs/ai.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<small>
|
|
2
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ AI Logic
|
|
3
|
+
</small>
|
|
4
|
+
|
|
5
|
+
# AI Logic
|
|
6
|
+
|
|
7
|
+
Firebase AI Logic gives you access to the latest generative AI models from Google: the Gemini models, including the Gemini image models.
|
|
8
|
+
|
|
9
|
+
[Learn more](https://firebase.google.com/docs/ai-logic)
|
|
10
|
+
|
|
11
|
+
> Firebase AI Logic was previously called **Vertex AI in Firebase**. If you are upgrading from AngularFire 20, the module moved from `@angular/fire/vertexai` to `@angular/fire/ai` and most symbols were renamed (`provideVertexAI` to `provideAI`, `VertexAI` to `AI`). One is not a rename: plain `getAI()` uses the Gemini Developer API backend, so the old `getVertexAI()` maps to `getAI(app, { backend: new AgentPlatformBackend() })`. Running the `ng update` command in the [AngularFire 20 to 21 upgrade guide](./version-21-upgrade.md) rewrites all of this for you and keeps your app on the same backend, though a call that passed no `location` moves from `us-central1` to `global`.
|
|
12
|
+
|
|
13
|
+
## Dependency Injection
|
|
14
|
+
|
|
15
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project as described in the [Quickstart](./install-and-setup.md).
|
|
16
|
+
|
|
17
|
+
Provide an AI instance in the application's `app.config.ts`:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
21
|
+
import { provideAI, getAI } from '@angular/fire/ai';
|
|
22
|
+
|
|
23
|
+
export const appConfig: ApplicationConfig = {
|
|
24
|
+
providers: [
|
|
25
|
+
provideFirebaseApp(() => initializeApp({ ... })),
|
|
26
|
+
provideAI(() => getAI()),
|
|
27
|
+
...
|
|
28
|
+
],
|
|
29
|
+
...,
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Next inject `AI` into your component:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { Component, inject } from '@angular/core';
|
|
37
|
+
import { AI } from '@angular/fire/ai';
|
|
38
|
+
|
|
39
|
+
@Component({ ... })
|
|
40
|
+
export class MyComponent {
|
|
41
|
+
private ai = inject(AI);
|
|
42
|
+
...
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Firebase API
|
|
47
|
+
|
|
48
|
+
AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
|
|
49
|
+
|
|
50
|
+
Update the imports from `import { ... } from 'firebase/ai'` to `import { ... } from '@angular/fire/ai'` and follow the official documentation.
|
|
51
|
+
|
|
52
|
+
[Getting Started](https://firebase.google.com/docs/ai-logic/get-started?platform=web) | [API Reference](https://firebase.google.com/docs/reference/js/ai)
|
package/docs/analytics.md
CHANGED
|
@@ -12,12 +12,9 @@ Google Analytics is an app measurement solution, available at no charge, that pr
|
|
|
12
12
|
|
|
13
13
|
## Dependency Injection
|
|
14
14
|
|
|
15
|
-
As a prerequisite, ensure that `AngularFire` has been added to your project
|
|
16
|
-
```bash
|
|
17
|
-
ng add @angular/fire
|
|
18
|
-
```
|
|
15
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project as described in the [Quickstart](./install-and-setup.md).
|
|
19
16
|
|
|
20
|
-
Provide
|
|
17
|
+
Provide an Analytics instance in the application's `app.config.ts`:
|
|
21
18
|
|
|
22
19
|
```ts
|
|
23
20
|
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
package/docs/app-check.md
CHANGED
|
@@ -12,15 +12,13 @@ App Check helps protect your API resources from abuse by preventing unauthorized
|
|
|
12
12
|
|
|
13
13
|
## Dependency Injection
|
|
14
14
|
|
|
15
|
-
As a prerequisite, ensure that `AngularFire` has been added to your project
|
|
16
|
-
```bash
|
|
17
|
-
ng add @angular/fire
|
|
18
|
-
```
|
|
15
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project as described in the [Quickstart](./install-and-setup.md).
|
|
19
16
|
|
|
20
|
-
Provide
|
|
17
|
+
Provide an App Check instance in the application's `app.config.ts`:
|
|
21
18
|
|
|
22
19
|
```ts
|
|
23
|
-
import {
|
|
20
|
+
import { ApplicationConfig } from '@angular/core';
|
|
21
|
+
import { provideFirebaseApp, initializeApp, getApp } from '@angular/fire/app';
|
|
24
22
|
import { provideAppCheck, initializeAppCheck, ReCaptchaV3Provider } from '@angular/fire/app-check';
|
|
25
23
|
|
|
26
24
|
export const appConfig: ApplicationConfig = {
|
|
@@ -32,7 +30,7 @@ export const appConfig: ApplicationConfig = {
|
|
|
32
30
|
...
|
|
33
31
|
],
|
|
34
32
|
...
|
|
35
|
-
}
|
|
33
|
+
}
|
|
36
34
|
```
|
|
37
35
|
|
|
38
36
|
Next inject `AppCheck` it into your component:
|
|
@@ -54,4 +52,4 @@ AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular,
|
|
|
54
52
|
|
|
55
53
|
Update the imports from `import { ... } from 'firebase/app-check'` to `import { ... } from '@angular/fire/app-check'` and follow the official documentation.
|
|
56
54
|
|
|
57
|
-
[Getting Started](https://firebase.google.com/docs/app-check/web/recaptcha-
|
|
55
|
+
[Getting Started](https://firebase.google.com/docs/app-check/web/recaptcha-provider) | [API Reference](https://firebase.google.com/docs/reference/js/app-check)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<small>
|
|
2
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Deploying SSR to Firebase App Hosting
|
|
3
|
+
</small>
|
|
4
|
+
|
|
5
|
+
# Deploying a server-rendered app to Firebase App Hosting
|
|
6
|
+
|
|
7
|
+
[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.
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
## How to deploy
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
## The symptom: SSR silently downgrades to CSR
|
|
16
|
+
|
|
17
|
+
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.
|
|
18
|
+
|
|
19
|
+
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.
|
|
20
|
+
|
|
21
|
+
App Hosting runs on Cloud Run, not Cloud Functions, so its logs live in Cloud Logging:
|
|
22
|
+
|
|
23
|
+
- In the Firebase console, open your backend and go to its **Logs** tab, then look at **Runtime logs**.
|
|
24
|
+
- From a terminal, use `gcloud`:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
gcloud logging read 'resource.type=cloud_run_revision AND resource.labels.service_name=YOUR_BACKEND_ID' --project YOUR_PROJECT_ID --limit 10
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
See Firebase's [View logs and metrics](https://firebase.google.com/docs/app-hosting/logging) guide for more.
|
|
31
|
+
|
|
32
|
+
## The 30-second check to run after every deploy
|
|
33
|
+
|
|
34
|
+
Pick an SSR route (not an SSG/prerendered one) and fetch it:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
curl -s https://YOUR-SITE/ | grep ng-server-context
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Angular's server renderer stamps a `ng-server-context` attribute on the app's root element:
|
|
41
|
+
|
|
42
|
+
- `ng-server-context="ssr"` - the route was server-rendered (SSR). This is what you want.
|
|
43
|
+
- `ng-server-context="ssg"` - the route was prerendered (SSG). Fine in itself, but not the SSR path this guide is about.
|
|
44
|
+
- **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.
|
|
45
|
+
|
|
46
|
+
## Why it happens
|
|
47
|
+
|
|
48
|
+
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.
|
|
49
|
+
|
|
50
|
+
<!--
|
|
51
|
+
Maintainer note (2026-07-19): the two-step fix below is a workaround for a lag in
|
|
52
|
+
Firebase App Hosting's build image. The underlying fix (injecting the full
|
|
53
|
+
X-Forwarded-* set into NG_TRUST_PROXY_HEADERS) is already merged upstream in
|
|
54
|
+
GoogleCloudPlatform/buildpacks (commit 9346e60b, 2026-06-17) but had not reached
|
|
55
|
+
production builders as of 2026-07-19. Once it ships, `npm update` alone suffices
|
|
56
|
+
and the trustProxyHeaders step becomes optional; revisit and simplify this guide.
|
|
57
|
+
-->
|
|
58
|
+
|
|
59
|
+
## The Fix
|
|
60
|
+
|
|
61
|
+
Two steps are needed together.
|
|
62
|
+
|
|
63
|
+
**1. Update Angular to the latest patch:**
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm update @angular/core @angular/ssr
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**2. Turn on proxy-header trust when you create the server engine.** In `src/server.ts`, pass `trustProxyHeaders: true` to `AngularNodeAppEngine`:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { AngularNodeAppEngine } from '@angular/ssr/node';
|
|
73
|
+
|
|
74
|
+
const angularApp = new AngularNodeAppEngine({
|
|
75
|
+
trustProxyHeaders: true,
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Redeploy, then run the 30-second check above. You should now see `ng-server-context="ssr"`.
|
|
80
|
+
|
|
81
|
+
### Why both steps
|
|
82
|
+
|
|
83
|
+
The two steps address different halves of the same handshake, and neither alone is enough:
|
|
84
|
+
|
|
85
|
+
- 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.
|
|
86
|
+
- Even on the latest patch, you still have to *set* the option, so App Hosting's proxy headers are trusted.
|
|
87
|
+
|
|
88
|
+
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).
|
|
89
|
+
|
|
90
|
+
> 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.
|
|
91
|
+
|
|
92
|
+
## Related Angular documentation
|
|
93
|
+
|
|
94
|
+
- [Angular SSR guide](https://angular.dev/guide/ssr)
|
|
95
|
+
- [Configuring trusted proxy headers](https://angular.dev/best-practices/security#configuring-trusted-proxy-headers)
|