Firebase Introduction

Jul 20, 2024

Firebase Introduction

Overview

  • Firebase: A suite of tools for building apps and managing infrastructure on Google Cloud Platform.
  • Founded by James Tamplin and Andrew Lee in 2011.
  • Initially inspired by developers using their chat software for non-chat data management.

Key Features

Real-time Database

  • JSON-based database automatically syncing with the front-end.

User Authentication

  • Supports various authentication methods including Google accounts.

Website Hosting

  • Acts as a Backend as a Service (BaaS).

Expansion by Google

  • Acquired by Google in 2014.
  • Introduced serverless computing via Cloud Functions.
  • Push notifications via Cloud Messaging.
  • Integration with Google services like Analytics and AdMob.

Firestore

  • New document database launched in 2017 following Google's acquisition of Fabric from Twitter.
  • Supports a wider range of applications.

Software Development Kits (SDKs)

  • Available for virtually every platform.
  • Enables management and scaling of infrastructure with minimal back-end code.
  • Facilitates full-stack application development.

Getting Started with Firebase

  1. Create a free Firebase project.
  2. Open code for your front-end platform.
  3. Install the Firebase SDK.
  4. Connect it to the cloud using your project credentials.
  5. Initialize and interact with backend resources.

Managing User State

  • Use onAuthStateChanged function to detect user login status.
  • Use signInWithPopup function for Google account login.

Data Storage and Real-time Updates

  • Store data in Firestore by referencing documents.
  • Use onSnapshot function to listen for real-time updates.

Security

  • Firestore Security Rules: Define access control using Common Expression Language.

Server-side Code

  • Use Firebase Cloud Functions for serverless back-end solutions.
  • Create HTTP endpoints.
  • Background function triggers for database writes, user auth events, etc.

Development and Deployment

  • Firebase Emulator Suite: Test code in a mock environment.
  • Firebase Deploy Command: Deploy code to the cloud and scale infrastructure.

Further Learning

  • Fireship.io: Web app built with Firebase to teach Firebase.

Conclusion

  • Firebase offers comprehensive tools for app development and infrastructure management.
  • Suitable for building full-stack applications with minimal backend effort.