Before moving into the topic How to host your website in firebase, let me explain what is Firebase.
Firebase provides Usage analytics to scale your applications performance, user category, country wise usage.With the help of Firebase, you can easily roll updates and rollback to previous versions without much stress in changing codes.
Now move on to the section How to host your website in firebase,
Create A Firebase Account:
First of all, sign in to firebase if you have an account or else signup using Gmail account.It will take you to the firebase console.A console is a front page for accessing functionalities of cloud platforms.Already have an account then login to console.firebase.google.com.
Create A project:
After logging into the firebase create a project by providing project name and location then proceed to create a project.After successful creation, it will take you to the project overview page.
Set Up Node.js:
You were almost done, now setting up node.js command prompt is necessary to host your website.In case you were using Windows download and install from here nodejs.org/en/.Download an LTS (long-term supported version).In case you were using Mac download .pkg file and install it.If you were using ubuntu use this command,
sudo apt-get install nodejs
After installing node.js integrate it with firebase
Integrate firebase and node.js :
To integrate firebase with node.js you have to download firebase-tools via npm (node package manager).In Windows search for node.js command prompt and start using it.For Mac and Linux users install it using the terminal.Use the below command to install firebase tools.
npm install -g firebase-tools
The above code will download the firebase tools into tour local machine.After installing the firebase packages login to firebase terminal by using the following command
It will take you to the browser to authenticate your firebase account.Use the same Gmail which is used for creating the project.
The above command will initialize and configure the firebase in your machine by creating two files .firebaserc and firebase.json. These files were created in the current working directory.You can change the path to the specified location (directory) and do the same steps.
Upload your website in firebase:
Before begin uploading create a folder and name it as
public and move the files you want to host or upload into that folder.And rename the home page or landing page into index.html in the public folder.
Once you have done moving the files into the public folder.All set for launch.
firebase deploy use this command to deploy your site and make visible to others.
To access your hosted website use PROJECT_NAME.firebaseapp.com.