Skip to content

Using Backend as a Service

In the previous lesson, we saw how to go about creating our own REST API and integrating it with our application. This is a reasonably common approach, but the more popular approach (especially for individual developers or smaller teams) is to use a Backend as a Service or BaaS solution.

Rather than building out the server yourself, and everything that might include like connecting to a database, managing user authentication, scaling for load, and so on — you can use a product with everything ready to go.

One of the most popular options is Firebase, and in the extended version of this course we will actually be building an application that uses Firebase. We will not be diving into how to use Firebase here, but the gist of it is this.

  1. You create an account for Firebase
  2. You create a project through their dashboard
  3. You will be given a configuration object/API key (this key is public)
  4. You install and use the SDK provided by Firebase to interact with the services they provide e.g. data storage, authentication, cloud functions, and more

Unlike with our own REST API we created where we were manually sending GET and POST requests, we wouldn’t actually do this with Firebase. Instead, we use their SDK to make requests like this:

login(credentials: Credentials) {
return signInWithEmailAndPassword(
this.auth,
credentials.email,
credentials.password
);
}

We don’t manually POST this data to the Firebase server, we just use the signInWithEmailAndPassword method provided to us by the Firebase SDK.

As you can probably see, this removes a lot of complexity and work that you would otherwise have to do yourself. But, you do have to pay for it (although Firebase does have a free tier so it is great for playing around with and learning).

Another important thing to note about these Backend as a Service options is that they know what they are doing. When it comes to something like user authentication it is critically important that you really understand the concepts and the potential security issues of certain approaches. It might be fun to play around yourself and create your own authentication system for learning purposes, but unless you already have strong experience in this area I would highly recommend never running your own authentication solution in a production environment. Even if you want to build your own server, you can still outsource just the authentication concerns to an external service like Auth0.

Other Backend as a Service Options

Although Firebase is extremely popular, there are other solutions available that are either currently popular or gaining in popularity. Here is a quick summary of some of those options:

  • Appwrite — this is a newer option which offers a lot of the same functionality as Firebase, but it is open source and can be entirely self hosted.
  • AWS Amplify — basically the same general idea as Firebase, but it’s Amazon instead of Google!
  • Supabase — this is another option that focuses on offering a similar feature set to Firebase but in an open source/self hosted flavour. It also uses Postgres for the database which is a relational style database as opposed to Firebase’s NoSQL document based database.

If you don’t really care about investigating different options right now, probably the easiest solution if you do want a backend but don’t want to sink too much time into it is to use Firebase. Firebase is very well established in the Angular ecosystem so you aren’t going to struggle to find help and code examples.