Repository navigation
chore(sample): update the sample app to Angular 22 - #3845
Draft
armando-navarro wants to merge 1 commit into
Draft
armando-navarro wants to merge 1 commit into
armando-navarro wants to merge 1 commit into
Conversation
Carries sample/ from Angular 21 to 22 with ng update, matching what ng new 22 generates: TypeScript 6, firebase 13, vitest 5, Node 24, provideBrowserGlobalErrorListeners, no explicit zoneless provider and no withIncrementalHydration (both are defaults now), the Eager change detection the migration adds removed again so the components run on the OnPush default. The server app is now built by initializeBrowserOrServerApp, which reads the ID token from the request context and releases the server app after the render. The old factory never released it. Calls to functions AngularFire does not wrap sit outside runInInjectionContext, with a comment on each, so the sample shows where the injection context is needed and where it is not. security.allowedHosts gains localhost: Angular 22 answers 400 to any host not on the list, so the built server could not be run locally. Both lockfiles regenerated with npm 10. Refs angular#3669
armando-navarro
added a commit
to armando-navarro/angularfire
that referenced
this pull request
Nov 11, 2026
The sample app now has one provideFirebaseApp with initializeBrowserOrServerApp in its shared app.config.ts (angular#3845), so the sentence about its split client and server files no longer holds. Refs angular#3843
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
README.mdis updated. No library docs change.app.component.spec.tsis updated for the new providers and name.yarn install,yarn testrun successfully?: yes, with npm, insidesample/on Node 24:npm install ../angular-fire-22.0.0.tgz,ng build,ng test(2 files, 4 tests).Description
Carries
sample/from Angular 21 to Angular 22, the way #3671 carried it from 19 to 21:ng update @angular/core@22 @angular/cli@22ng new22 generatesinitializeBrowserOrServerAppfrom feat(app): add initializeBrowserOrServerApp for browser & server apps #3844, which replaces the hand-written server-app factory and releases the server app the old factory never released.Changes
@angular/*22.2, TypeScript 6.0,firebase13,vitest5,jsdom30,@types/node22, theng22-testname, and Node 24 (firebase 13's packages require it).app.config.tsmatches the 22 scaffold:provideBrowserGlobalErrorListeners()addedprovideZonelessChangeDetection()dropped (zoneless is the default)provideClientHydration()withoutwithIncrementalHydration()(incremental hydration is the default).Removed
ChangeDetectionStrategy.Eagerthat Angular'schange-detection-eagermigration added to all nine components again (so it does not appear in the diff), and the sample runs on Angular 22'sOnPushdefault.app.config.ts: oneprovideFirebaseApp(() => initializeBrowserOrServerApp(environment.firebase))for both platforms, as step 4 of the Authentication guide shows.server.tsalready passes tohandle(), builds a Firebase server app for a signed-in render and the ordinary app otherwise, and releases the server app once the render is garbage-collected.app.config.client.tsis deleted. Its browser-only providers (Analytics with the two tracking services, Messaging, Performance) move toapp.config.ts, since each already provides nothing on the server, andmain.tsbootstraps fromappConfig, asng newdoes.app.config.server.tskeeps onlyprovideServerRendering.Calls to functions AngularFire does not wrap (
doc,collection,query,orderBy,increment,serverTimestamp) sit outsiderunInInjectionContext, with a one-line comment on each.GoogleAuthProvider,onIdTokenChangedandsignInWithPopupare imported from@angular/fire/auth.onAuthStateChangedstays the SDK's own inside the sample'sauthState, which applies the wrapper to the whole function.server.tskeeps thetrustProxyHeaders: ['x-forwarded-host', 'x-forwarded-proto']thetrust-proxy-headersmigration wrote, with a comment in place of its TODO.angular.json:security.allowedHostsgainslocalhost.400 Bad Requesterror to any host not on that list (Angular 21 logged an error and fell back to client-side rendering), and it was empty, sonpm run serve:ssr:ng22-testcould not be reached locally.README.mdhas a "Running the server build" section that says deployments add their hostnames there or inNG_ALLOWED_HOSTS.tsconfig.app.jsonkeeps theextendedDiagnosticsblock thestrict-safe-navigation-narrowmigration wrote.functions/package.jsonmoves to the Node 24 runtime. Bothpackage-lock.jsonfiles regenerated with npm 10.Behavior to know
EBADENGINEwarnings for thefirebasepackages.Verification
ng buildandng test(2 files, 4 tests) on Node 24.22.2, with one copy offirebase(npm ls firebase).firebase emulators:exec --import seedwith the production server bundle):uid.ng serve, where AngularFire's injection-context warning prints: sign-in, a write and the function call with no AngularFire warning.@deferblocks on incremental hydration.npm run buildof the Cloud Function from its regenerated lockfile.Not exercised: "New animal" (a
window.prompt), "Log in with Google" (a real provider popup), Messaging (no token flow in the emulators).