Tech I Used Last Week => Google Firebase

Robert K.
5 min readAug 16, 2020
Photo by Jon Tyson on Unsplash

Being a recent bootcamp graduate from the Flatiron School’s software engineering program has taught me many things. Not the least of which is ‘find the right technology for the job.’ If there is a library, framework, open source package or service out there which can get you to your MVP faster, generally speaking, it’s a good idea to take advantage of it. There may be a learning curve to get it connected to your application but the ROI comes back in leaps and bounds when you are sipping your beverage and looking at MVP thinking about which stretch goal to attack first. I applied this strategy recently with Google Firebase and its real time database.

I am working on a deep dive into React via a course on Udemy, complete with a course long project which you will write, then re-write with additional routing, then re-write with Redux, then re-write a last time with React Hooks, and finally deploy. The course is obviously tailored to giving you as much time to flex your front end muscles as possible.

This doesn’t mean that your application can be only a React front end with no database or stored information. Any application would be super lame if every time you reloaded the page you lost all of your work. Enter Firebase, Google’s suite of solutions to a whole host of common app development problems.

I should note at this point that I implemented the real-time database and the authentication of users through Firebase but there is a laundry list of products offered that I have not gotten the chance to explore just yet.

So why use Firebase?

For starters, it was dead simple to get set up and back to build. It also helps that their free tier gives you plenty of room to have a personal project app without having to fear going over and being surprised by a credit card bill.

Also, the docs are very well written. They have examples for different platforms like iOS, Android, Web, Unity, and C++ so you can see how to implement something clearly based on how you are trying to use it.

Some more about the set up

If you have a google account you are already halfway to having your app and database set up. You’ll log into your google account and be taken to a dashboard where you can manage your projects, add a new project or explore a demo project to run you through some of what Firebase can do.

Setting up a project is 2 simple steps.

  1. Name it
Step 1 of creating a new app

2. Choose to add Google Analytics (or not) => If you choose to add google analytics you’ll need to connect an account.

Step 2 of creating a new app

Congratulations! It’s an app!

Once the app has finished getting connected you’ll be taken to its console where you can get a snap shot of different menu options to explore. The sidebar on the left is where your four major menus live. To connect a database we’ll go to the Developmenu and the database section.

Firebase Application ‘home’ view

You’ll be given a choice between types of databases here. For my needs I went with the Realtime Database. The creation of the database will walk you through getting started in development mode or keeping read and write access blocked. I started in test mode.

And. Well. That’s pretty much it. Your database is now running. Need to send a post request? Go right ahead. The docs provide explanations and best practices for structuring your data and writing your basic http requests using built in firebase methods, or a separate request library like Axios.

The real beauty comes with being able to work directly with the database. Adding or removing sections or records as you need. A real helpful trick when in development of something.

Let’s do some quick

Here is the database ( in JSON format ) that we just created.

Our newly formed ( and empty ) database

Let’s say we are building a workout tracking app. We are going to need some workouts to choose from and let’s say a connection of a user and doing a workout called userWorkout. Adding these to our database is as easy as actually typing them in. Take a look.

Adding to the database

The nodes for userWorkouts and workouts were added the same was as these records. That’s a real time update done on the server that we can now query and receive as response data. Removing items? Just as simple.

The database is also pretty smart. So if you send a post request to an endpoint you don’t have yet it will create it for you. Handy when you are first testing things and want to make sure it comes across the right way. Easier than adding a test table to your schema.

My Opinion?

It went together fast. Reading and writing data to it happens in a flash and the free tier is more than enough for what I need. The docs are well written and contain examples that are very useful and almost good enough to copy and paste. Also there are tons of other features and pieces to the Firebase suite you can add to your application to help with other common development issues. I experimented with the authentication, but that’s a topic for another blog ( spoiler alert it was just as easy )

Happy Hacking!

Resources

Connect with Me

--

--

Robert K.

Full- Stack Software Engineer with a former life in high-end restaurant management. Currently working in React JS and Ruby on Rails.