Hosting multiple sites in Firebase

by | Feb 12, 2019 | Uncategorized

Blogs arrow Hosting multiple sites in Firebase

Hosting multiple sites in Firebase


Feb 12, 2019


Hosting multiple sites with firebase

Problem Statement

Firebase is a nice platform for developers to quickly develop smart apps. I would like to share some experience regarding the github issue with firebase discussed here. . The root cause of the problem is that the `firebase target:apply` doesn’t change `firebase.json` — it only effects `.firebaserc`.

How to deploy multiple sites then ?

As a developer, i came across of the problem of trying to deploy multiple sites under a single firebase project. Let’s say you want to build a web app with an admin platform and a customer facing site. We would normally want to share the same project and host different sites under one project.


Image showing two hosting sites under a single project

A traditional firebase app deployment steps are listed here . Assuming you want to deploy more than one app under different hosts within the same project, you will follow standard firebase instructions listed here

If you try the link you will notice that, the default firebase.json does not get updated when you try
firebase target:apply hosting {yoursite-alias} {yoursite-name-in-firebase} [this command updates only the .firebaserc]


Follow the below instructions to fix the problem

1. firebase target:apply hosting ecom-alias ecomadmin

2. change the firebase.json to have entries for each hosting site like


ecom-alias in this image is mapped to the ecomadmin site under firebase

3.firebase deploy — only hosting:ecom-alias


1.firebase login
2.firebase init

(make some selections and then you see this)

Wrote public/index.html

i Writing configuration info to firebase.json

i Writing project information to .firebaserc

i Writing gitignore file to .gitignore

 Firebase initialization complete!

3.firebase target:apply hosting ecom-alias ecomadmin

Applied hosting target ecom-alias to  ecomadmin

4. firebase deploy — only hosting:ecom-alias

=== Deploying to ‘firenut-5411a’…

i  deploying hosting

i hosting[ecomadmin]: beginning deploy…

i hosting[ecomadmin]: found 1 files in public

✔ hosting[ecomadmin]: file upload complete

i hosting[ecomadmin]: finalizing version…

✔ hosting[ecomadmin]: version finalized

i hosting[ecomadmin]: releasing new version

✔ hosting[ecomadmin]: release complete

✔ Deploy complete!

Project Console:

Hosting URL:

More Blogs