Firebase - My New Favorite Toy
Allow me to sing Firebase's praise for a second.
<html> <head> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> </head> <body> <script> var myDataRef = new Firebase('https://<INSERT-FIREBASE-NAME-HERE>.firebaseio-demo.com/'); </script> </body> </html>
It implements a JSON style database, with all of your data written into one file. The data is synchronised between all of the connected clients in real time, meaning that everyone will always have the most current data to use. This is especially useful when making a chat client or news feed, as it doesn't require the user to refresh the page, or a periodic AJAX call.
There are various forms of user authentication that you can use. You can choose to use a simple Email and Password combination, which Firebase handles with ease (including being able to customise the email that gets sent to users who have forgotten their passwords). oAuth is also an option, with access to Facebook, Twitter, Google and Github. And finally, you can use your own authentication server to log users into your system. The details about the user are stored in the database, with access granted to those with clearance. And this is all done on the client side!
The security of your database is dependent on your situation. For this reason, Firebase leaves it up to you to write your security rules, however this is simply a JSON file that you can specify which parts of the database can be accessed by who, or when. There is an excellent guide provided to help you set this up, so this isn't as daunting as it may seem.
On the subject of guides, the documentation for Firebase is extensive. It includes examples that have been created to show off what can be done, and how easy it is. There is a "quickstart" section under every platform so that you can get yourself up and running in under 5 minutes, and if you're really stuck, then there are several pre-made recipes that you can drop into your code that will add that functionality.
But that's not all! Firebase can also host your site for you! Every app has its own
firebaseapp.com domain, with paid apps having access to custom domains.
And the best part about all of this? It's free! There is a tiered pricing structure if you plan to use Firebase in production, but for PoC and small apps, the free version is plenty. I've included the pricing structure below, which is correct as of 12/08/2015. For the most up to date prices, visit Firebase Pricing
If you have 5 minutes spare, I implore you to try it out. There is a Tutorial that will walk you through making a simple messaging system. All you need is the ability to copy and paste! It's certainly an invaluable tool in my Web Dev Arsenal, and if, like me, you create websites frequently that require authentication and a database connection, then this could be invaluable for you too.
I will shortly be writing a series of blog posts that go into Firebase in more depth, creating a simple website that has all of the functionality you are most likely going to need to use when creating your own. So make sure to stay tuned!