Search code examples
htmlcssfirebasefirebase-authenticationfirebase-hosting

Can three web-pages be inside the same project in Firebase (Firebase Hosting)?


Let's say I created a project in Firebase called ExampleApp.

I created a page with a form to be submitted. It is being hosted by Firebase. The database (Cloud Firestore) is storing the data submitted by the user when he/she fills the form and click on the submit button.

There should be a way to present this data beautifully to the person who is responsible for analyzing it.

So, some specific person responsible for reading the data need to be able to login with some credentials created by me and then see the data beautifully organized.

So, given the fact that I need to create another webpage (or anything that allows me to accomplish my task), such that the admin can access through authentication (a page with username/password form) and get to see the database in a beautiful layout, do I need to create another project in Firebase?

It would be great If I could achieve all of this inside the same project in Firebase, but it seems Firebase hosting can only host a single web-page, right?

They can all have the same domain.


Solution

  • You can add as many pages as you want in your Firebase hosting directory, along the index.html page (which you could rename by the way). You can even organised them with sub-directories. All of that within one Firebase project.

    What is important to understand is that your pages are not going to be protected by authentication/authorization, but rather the data which is displayed in the pages.

    For example, your page with the "data beautifully organised" could be acccessed by anybody who has its URL, but without the correct authentication/authorization the user will not see the data which is supposed to be displayed in this page, coming from the Firebase database (Real Time DB or Firestore). You ensure that by setting the correct security rules at the level of the database.

    So, to say it with other words, the containers are totally public (for the ones who know how to call them with their URL) but the content is protected by the Firebase authentication mechanism AND the security rules you have declared at the database level (authorization).