Firebase

What is Firebase

Firebase is a Google's offering. It's a suite of cloud offerings specially designed for building single page progressive applications for web or mobile. It provides you static page hosting (html, css, javascript), no sql database, real time eventing and lot more.

It also provides tolling to run your app locally in emulator and also non prod environments.

It frees you from concerns of scaling or infrastructure management.

Project and Apps

When you open firebase console, you can see

https://firebase.google.com/docs/hosting/multisites


Getting started

install firebase ools


Open Firebase console in your browser. You should be able to see all your firebase projects with an option to create new projects.

mkdir firebase

cd firebase

mkdir firebase-demo

firebase init

You may not get these names due to I have reserved them as soon as I created them for web.app domain

firebase hosting:sites:create game-scorer

firebase target:apply hosting scorer game-scorer


firebase hosting:sites:create scoreboard-view

firebase target:apply hosting scoreboard scoreboard-view


create folders

Change firebase.json (including array and add site for default)


firebase emulators:start --only hosting

firebase emulators:start --only hosting:scorer

firebase emulators:start --only hosting:scoreboard

npm run build

npx create-react-app score-app-react

firebase deploy

deploying preview

firebase hosting:channel:deploy preview-name

firebase hosting:channel:deploy preview-name --only scorer

https://blog.logrocket.com/rest-api-firebase-cloud-functions-typescript-firestore/


Choosing tier

https://firebase.google.com/pricing/

Limitation ion database, buckets etc in free tier

Multisite is available in free tier


Setting custom domain

https://firebase.google.com/docs/hosting/custom-domain




To mirror your workflow environments (for example, Dev, Q1, Q2, Prod), we recommend that you create a separate Firebase project for each environment rather than creating multiple sites in a single Firebase project. Generally, you don't want to use production-environment Firebase resources (like customer data in a Realtime Database) in a development environment. Consider using automatic SDK configuration to mirror multiple environments using a single codebase.