/ angular

Lightweight alternative to AngularFire

First of all, let me say that if you already use AngularFire and don't have any issues with it, then you should probably continue doing so, as it is the official Angular library for Firebase.

Having said that, let's see why you might consider an alternative: ng-firebase-lite.

AngularFire is a quite big library that wraps all or most API's from Firebase SDK with a goal to make them easier to use in the Angular context and take advantage of RxJS power. ng-firebase-lite, on the other hand, doesn't attempt to wrap any API's, but just provides a convenient way to access Firebase SDK in a form of a simple FirebaseApp service that you can inject anywhere in your app.

In fact, it is almost not worth having a library at all, as it is so small (just one module) that you can just copy it to your project and have full control over how you work with Firebase SDK.

Now, the reasons why you might opt into this more lightweight approach might include:

  • Bundle size. As mentioned above, this library doesn't add much on top of Firebase SDK, so the footprint is tiny.
  • Program closer to the official API of Firebase SDK. This is convenient because all the examples in the official docs for Firebase (at https://firebase.google.com/docs) as well as StackOverflow answers will be directly applicable (as opposed to having to find the analogous API's in the docs of AngularFire).
  • No or little difference with Firebase Admin Node.js SDK, which you would use to access Firebase from Cloud Functions on the server.
  • Use newer Firebase API's sooner. When new capabilities are added to Firebase, it can take some time before they are available via AngularFire and issues like this appear. For example, Cloud Messaging support is still not available.
  • Less code = less complexity = less bugs. Consider the issue list for angularfire2. Also consider that angularfire2 hasn't had a stable release yet and is in RC stage for almost a year now (!).

All in all, I would say that personally for me the added convenience of observable API that AngularFire provides wasn't worth the cost. From very beginning it seemed a little strange having a wrapper API on top of another "official" JavaScript API from Firebase SDK. It just seems that it is bound to having inconsistencies and all sorts of strange bugs.

If any of the above sounds familiar, go ahead and give ng-firebase-lite a try, or as I said above, the library is so tiny that you can just copy the code to you project and have full control over how you integrate Firebase into your app. The main point is to use Firebase SDK as directly as possible.

Pavlo Glazkov

Pavlo Glazkov

Programmer. Full stack, with a focus on UI. JavaScript/TypeScript, Angular, Node.js, .NET

Read More