Intro to Firebase ( 4 minute read )
Get to Know Firebase under 4 minutes
Firebase, a suite of tools for building apps and managing infrastructure on top of Google Cloud
Platform, was founded by James Tamplin and Andrew Lee in 2011 after they discovered that
developers were using their chat software to manage non-chat application data. This inspired
them to create a real-time database, a JSON database that automatically stays in sync with your
front-end application. It was later expanded to support user authentication and website hosting
to act as a complete backend as a service.
In 2014, it was acquired by Google where it was further expanded with serverless computing
via Cloud Functions, push notifications via Cloud Messaging, and other Google services like
Analytics and AdMob. In order to serve a larger range of applications, Google introduced
Firestore, a new document database, along with the acquisition of Fabric from Twitter in 2017.
The most crucial thing to remember is that Firebase offers software development kits for
almost all platforms, allowing managers to expand and manage this infrastructure with very
little or no back-end code. To build a full stack application, create a free Firebase project, then
open up some code for your favorite front-end platform, install the Firebase SDK, then connect
it to the cloud with your project credentials.
Once initialized, you can start interacting with your backend resources. First, we might want to
know if the user is logged in or not. We can listen to the current user with the on-off state
changed function. The user will be null at first, but we can log them in with their Google
account using the sign-in with pop-up function. Now that we have a user logged in, we might
want to store something in a database.
We can make a reference to a document in Firestore, then write JSON data to it while making a
reference to the current user's user ID. The incredible part is that, by just referencing the
document and utilizing the on Snapshot method, we can listen to modifications to that data in
real time.
Optimistic updates from the box ensure that anytime the data changes on the server, it will be
reflected in the user interface with no lag. However, it doesn';t seem particularly safe. How can
we limit who is able to access the database? Using Common Expression Language, you may
build access control logic for Firestore security rules in an easily understandable style.
You can do almost everything from the front end, but when you do need to run server-side
code, Firebase Cloud Functions provides a tightly integrated serverless backend. Not only does
it allow you to create HTTP endpoints, but functions can also be triggered in the background
based on events that happen in your project like writes to the database, user authentication
events, file uploads, and many others.When developing locally, Firebase has an emulator suite to run and test your code in a mock environment. When it's time to deploy, run the Firebase deploy command to push your code to the cloud and allocate infrastructure to run it at any scale.
Comments
Post a Comment