OVERVIEW
In this blog, you will learn,
1. How to install Nodejs and npm
2. How to login/logout to Firebase through CLI
3. How to host a website on firebase for free
To host a website on firebase you must have node.js and npm installed on to your system. If you already have it installed on your system, then you don’t have to install it again. But if you don’t have it installed on your system then follow the steps given below.
How to install Nodejs and npm
Firstly, let’s verify if node.js and npm are installed on to your system or not. For that open the terminal or command prompt on your system and type the given commands.
node --version
npm --version
If you will get the out like the shown above that means you already have the nodejs and npm installed on your system and you don’t have to install it again and you can skip this step. If you get something else that means you have to install it now. Use the process given below according to the operating system you are using.
Ubuntu/MAC
sudo apt update
sudo apt install nodejs
sudo apt install npm
After the successful execution of the above commands, you will have nodejs and npm installed on your system and you can verify them with the previous commands. You can also check this link for the installation of nodejs
Windows
For installing node js and npm on Windows operating system, go to the official website of node js and download the node version according to your system configuration and install it. With this, you will have node js installed on your system and now you can use the npm (node package manager) to set up and host a website on firebase. After the successful installation of npm on your system, now run the given command in the terminal or command prompt to install the firebase tools that will help you login/logout or to host a website on firebase.
npm install -g firebase-tools
Keep in mind that you have to install this tools only once on your system because you can install it even twice and if you will try to do so then it will show you some errors like its not getting installed and for the clarification you can check this video.
How to login/logout to Firebase through CLI
Now, to move to the next step first make sure that you have the complete source code in a single directory with the name of your choice and the main page, or let’s say the home page should be named as index.html so that firebase can recognize it. Once you are done with this, now open the terminal or command prompt and switch to the directory where you have your project directory and run the following commands.
firebase login
Firstly, you have to login to the firebase account where you want to host your website and follow the instructions as shown below.
Also, if you are already logged in with some different account then use the given command to logout and try the above command again to login.
firebase logout
How to host a website on firebase for free
Now, it’s time to host a website on firebase and to make it live on the firebase free hosting. Now run the given command and host a website on firebase,
firebase init
firebase deploy
Now, that you have Hosted a website on firebase and also you have deployed it. In the above image, you can see that you have got a public URL which is the global URL for the website that you just hosted. You can also check my website here: https://demowebsite-791a5.web.app
Now if you want to host this URL on the domain of your choice then you can check this video and learn how to link any public IP address or URL with any domain name.
This is all about HOW TO HOST A WEBSITE ON FIREBASE FOR FREE. I hope you have got a crystal clear understanding of it. But still, if you are facing any difficulties in understanding and implementing it. Feel free to leave a comment below in the comment section.
Stay Tuned and Happy Learning. 🙂
2 thoughts on “EASIEST WAY 2 HOST A WEBSITE ON FIREBASE FOR FREE”