Firebase vs AngularFire

Ravi Shankar Bharti picture Ravi Shankar Bharti · Jan 10, 2017 · Viewed 10.3k times · Source

I am working on an Angular App, which is connected with Firebase Real-time database. I am currently using AngularFire for accessing Firebase database.

After reading Vanilla Firebase and AngularFire documentation, and after implementing some portion of my app, I saw that all the things required from Firebase database can be achieved with the help of Vanilla Firebase, without any help of AngularFire.

Also, AngularFire provides only limited number of resources as compared to Vanilla Firebase. So, why would I want to use AngularFire, instead of Vanilla Firebase, when it has many resources available with it? I cant get my head around this scenario.

What are the benefits of using AngularFire over Vanilla Firebase?

Answer

Luis Fernando Alves picture Luis Fernando Alves · Jan 12, 2017

Angularfire

Well, angularfire is sort of a helper library. It's supposed to make your life easier by providing bindings that were created in order to make the integration between angular and firebase more seamless.

A practical example:

Developers normally need to make use of arrays in order to display data. However, firebase does not store any data in array form. Instead, it uses a JSON-like structure. That being said, to make it easier for everyone to wrap their heads around retrieving data from firebase as an array, angularfire gives you $firebaseArray(), which essentially converts the data from a certain location and returns you that same data inside of an array (a read-only pseudo-array).

Note that all of that could be accomplished by just retrieving the data manually with vanilla firebase and then converting the data you got from firebase (as an object) to an array on the client side.

You should use angularfire when it makes sense to you and if it makes your life easier. That is what it is there for. If you can accomplish everything you need by just using vanilla firebase, there's no reason to complicate things. I should also point out that you can use firebase and angularfire at the same time. As cartant mentioned in the comments, it is not an either-or choice, as both play together very well. That means that you can use vanilla firebase for more specific use cases, while utilizing angularfire for other purposes.

All in all, everything that is possible to do with angularfire is also possible with vanilla firebase, although it may require a whole bunch of extra code. In other words, angularfire is built on top of firebase and will not offer you new firebase features. Essentially, it makes using firebase with angular a lot more fun and practical.

Angularfire2

Angularfire2 is a totally different story, since it actually integrates RxJS observables and other reactive patterns with firebase, all of which are not available by default in vanilla firebase.

For the most part though, they both serve the same purpose. Angularfire2 is also an abstraction on top of firebase that provides real time bindings which were meant to facilitate the integration between firebase and angular2. Additionally, it gives you the possibility of working with firebase in a reactive way.