Skip to content

Commit ec28238

Browse files
committed
feat(angular): upgraded to SSR/hybrid. Routes added for ssr, ssg and csr
1 parent 39c8058 commit ec28238

File tree

7 files changed

+89
-22
lines changed

7 files changed

+89
-22
lines changed

examples/angular/angular.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"styles": ["src/styles.css"],
2727
"scripts": [],
2828
"server": "src/main.server.ts",
29-
"prerender": true,
29+
"prerender": false,
3030
"ssr": {
3131
"entry": "src/server.ts"
3232
}
@@ -36,8 +36,8 @@
3636
"budgets": [
3737
{
3838
"type": "initial",
39-
"maximumWarning": "500kB",
40-
"maximumError": "1MB"
39+
"maximumWarning": "1MB",
40+
"maximumError": "2MB"
4141
},
4242
{
4343
"type": "anyComponentStyle",

examples/angular/package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
"format:check": "prettier --check \"src/**/*.{ts,html,css,scss}\""
1919
},
2020
"dependencies": {
21-
"@angular/animations": "^19.1.0",
22-
"@angular/common": "^19.1.0",
23-
"@angular/compiler": "^19.1.0",
24-
"@angular/core": "^19.1.0",
25-
"@angular/fire": "^19.0.0",
26-
"@angular/forms": "^19.1.0",
27-
"@angular/platform-browser": "^19.1.0",
28-
"@angular/platform-browser-dynamic": "^19.1.0",
29-
"@angular/platform-server": "^19.1.0",
30-
"@angular/router": "^19.1.0",
31-
"@angular/ssr": "^19.1.7",
21+
"@angular/animations": "^20.2.2",
22+
"@angular/common": "^20.2.2",
23+
"@angular/compiler": "^20.2.2",
24+
"@angular/core": "^20.2.2",
25+
"@angular/fire": "^20.0.1",
26+
"@angular/forms": "^20.2.2",
27+
"@angular/platform-browser": "^20.2.2",
28+
"@angular/platform-browser-dynamic": "^20.2.2",
29+
"@angular/platform-server": "^20.2.2",
30+
"@angular/router": "^20.2.2",
31+
"@angular/ssr": "^20.2.2",
3232
"@firebase-ui/angular": "workspace:*",
3333
"@firebase-ui/core": "workspace:*",
3434
"@firebase-ui/styles": "workspace:*",
@@ -42,9 +42,9 @@
4242
"zone.js": "~0.15.0"
4343
},
4444
"devDependencies": {
45-
"@angular-devkit/build-angular": "^19.1.7",
46-
"@angular/cli": "^19.1.7",
47-
"@angular/compiler-cli": "^19.1.0",
45+
"@angular-devkit/build-angular": "^20.2.2",
46+
"@angular/cli": "^20.2.2",
47+
"@angular/compiler-cli": "^20.2.2",
4848
"@eslint/js": "^9.22.0",
4949
"@tanstack/angular-form": "^0.42.0",
5050
"@types/express": "^4.17.17",
@@ -60,8 +60,8 @@
6060
"karma-jasmine": "~5.1.0",
6161
"karma-jasmine-html-reporter": "~2.1.0",
6262
"nanostores": "^0.11.3",
63-
"ng-packagr": "^19.1.0",
63+
"ng-packagr": "^20.2.0",
6464
"prettier": "^3.1.1",
65-
"typescript": "~5.7.2"
65+
"typescript": "~5.9.2"
6666
}
6767
}

examples/angular/src/app/app.config.server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
*/
1616

1717
import { mergeApplicationConfig, ApplicationConfig } from "@angular/core";
18-
import { provideServerRendering } from "@angular/platform-server";
18+
import { provideServerRendering, withRoutes } from "@angular/ssr";
19+
import { serverRoutes } from "./app.routes.server";
1920
import { appConfig } from "./app.config";
2021

2122
const serverConfig: ApplicationConfig = {
22-
providers: [provideServerRendering()],
23+
providers: [provideServerRendering(withRoutes(serverRoutes))],
2324
};
2425

2526
export const config = mergeApplicationConfig(appConfig, serverConfig);
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { RenderMode, ServerRoute } from "@angular/ssr";
18+
19+
export const serverRoutes: ServerRoute[] = [
20+
/** Home page - perfect for SSG as it's a static landing page */
21+
{
22+
path: "",
23+
renderMode: RenderMode.Prerender,
24+
},
25+
/** Key auth screen demos - good for SSG as they showcase Firebase UI components */
26+
{
27+
path: "screens/sign-in-auth-screen",
28+
renderMode: RenderMode.Prerender,
29+
},
30+
{
31+
path: "screens/oauth-screen",
32+
renderMode: RenderMode.Prerender,
33+
},
34+
{
35+
path: "screens/sign-up-auth-screen",
36+
renderMode: RenderMode.Prerender,
37+
},
38+
{
39+
path: "screens/email-link-auth-screen",
40+
renderMode: RenderMode.Prerender,
41+
},
42+
{
43+
path: "screens/phone-auth-screen",
44+
renderMode: RenderMode.Prerender,
45+
},
46+
/** Interactive auth routes - better as CSR for user interaction */
47+
{
48+
path: "sign-in",
49+
renderMode: RenderMode.Client,
50+
},
51+
{
52+
path: "register",
53+
renderMode: RenderMode.Client,
54+
},
55+
{
56+
path: "forgot-password",
57+
renderMode: RenderMode.Client,
58+
},
59+
/** All other routes will be rendered on the server (SSR) */
60+
{
61+
path: "**",
62+
renderMode: RenderMode.Server,
63+
},
64+
];

examples/angular/src/main.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ import { bootstrapApplication } from "@angular/platform-browser";
1818
import { AppComponent } from "./app/app.component";
1919
import { config } from "./app/app.config.server";
2020

21-
const bootstrap = () => bootstrapApplication(AppComponent, config);
21+
const bootstrap = (context: any) => bootstrapApplication(AppComponent, config, context);
2222

2323
export default bootstrap;

packages/angular/ng-package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@firebase-ui/core",
99
"@firebase-ui/styles",
1010
"@tanstack/angular-form",
11+
"firebase",
1112
"nanostores",
1213
"tslib",
1314
"zod"

packages/angular/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
}
1515
},
1616
"scripts": {
17+
"prepare": "pnpm run build",
1718
"build": "ng-packagr -p ng-package.json",
1819
"test": "ng test --watch=false --browsers=ChromeHeadless --project=firebase-ui-angular",
1920
"test:watch": "ng test --watch=true --project=firebase-ui-angular",

0 commit comments

Comments
 (0)