I give up on AngularFire
Stephen Fluin
Posted on May 25, 2024
I just worked really hard to rip AngularFire (@angular/fire
) out of my codebase.
If you don't know, AngularFire used to be awesome. This was best around 2019-2020, but after being under-served and failing to fully finish several migrations (the Firebase SDK now uses a modular approach), it's kind of a mess.
I tried and failed to update from v6 up to v16, v17, and beyond, because I wanted to use Angular 18. This didn't work (ng update
would refuse to update to v16 because it forces only updating one major at a time, which is a bit silly), so I ended up deciding to rip it out.
Steps to remove
- Remove
@angular/fire
from your package.json - Swap out the
AngularFireModules
for your own keys
providers: [
{ provide: BUCKET, useValue: '...'},
{ provide: FIREBASE_APP, useFactory: () => initializeApp({...})}
- Create a service that calls
initializeApp
fromfirebase/app and save your
FirebaseApp.
constructor(@Inject(FIREBASE_APP) private fbApp: FirebaseApp) {
` - Create (or use the same) a service for each of the Firebase modules you want to use, and then get a persistent handle on the service you want.
typescript db = getDatabase(this.fbApp); storage = getStorage(this.fbApp); auth = getAuth(this.fbApp);
Here's the commit on the fluin.io repo.
💖 💪 🙅 🚩
Stephen Fluin
Posted on May 25, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.