Hosting A Static Website On Firebase For Free
Last Updated :
26 Nov, 2020
Building a web application is always a time-consuming job, especially for the beginner developers who have just landed their feet in the vast world of programming. And one of the most exciting parts is when the application is available for all to see. Being a new bee in programming most beginners lack the knowledge of hosting, servers, and how to present their project to the end-user. And this is exactly the problem Firebase is going to solve for us. Although we have a couple of other ways to host a website for free like GitHub pages, netlify, Firebase is considered best as it gives developers a ton of functionalities to choose from. Here, we will see how one can host his/her static website on firebase just in a couple of minutes and that too free.
Firebase is a platform developed by Google to help developers create and grow mobile and web applications faster. It does help the developers by providing a ton of backend functionality to developers such as Cloud Firestore (a real-time database), Firebase ML (deploys machine learning models), Authentications (authentication service), Hosting (best in class hosting service), etc. Here we will be using the hosting service to deploy our static website because it is low latency hosting which will automatically secure our website with an SSL certificate in addition to providing many other features. And the most important thing its free up-to one gigabit of storage for a single project, which is more than enough for most of the projects.
Prerequisites:
- A Gmail Account, which will be required to sign-in to firebase.
- Node JS, is required to install Firebase-CLI (command-line interface) which will deploy or website to the servers.
- You must be ready with a static website. The website we will be deploying here is a tutorial website.
Step 1: Creating a new project and a web instance in firebase
Visit firebase.google.com, sign in with your Gmail account. And after signing-in go to console and add a new project.
Give the project a name of your choice here I have given 'geeksforgeeks'. And go through other following step without selecting Google analytics (for simplicity) and your project will be ready in ten seconds.

Step 2: Open the website in an IDE
Now, we need to open the folder containing the website's files in an IDE. And open a terminal. Here I am using VS Code.

Step 3: Register App
The project dashboard will look something like this. Here click on the web button (circled red). Which will create a web instance of our project.
Now here it will ask for a name that we want to give our website (web instance). You can choose one, select 'Also setup Firebase Hosting', and click on the register app.
Step 4: Add Firebase SDK
Now, we will be given a code snippet that has to be pasted in the body of our website's home page.
Something like this.
Step 5: Installing Firebase CLI
After pasting the script in the body go back to the firebase and click next. Now, you will be presented with a command 'npm install -g firebase-tools' which need to be run in the terminal where we have our website's files.
This is how it would look. This command will install firebase CLI on our machine. It may take from a few seconds to a couple of minutes to install depending on your internet speed. And after doing this click next on the website.
Step 6: Deploying to firebase hosting
Now, in the firebase website were given commands which should be run in order to deploy our website to firebase hosting.
We can copy each code and paste it into the terminal and hit enter to run it. The first is 'firebase login'.
Now running 'firebase init' we will get the following options. Click y and hit enter.
Here, we need to choose Hosting: Configure and deploy Firebase Hosting sites, (by clicking the space-bar) as this is the service we want.
Now, it will ask whether we want to create a project or use an existing one. We will choose the existing as we have already created the project.
Here, I am getting geeksforgeeks-gf7c3 (the web instance we created) as one of the options. I will choose this because we want to deploy our website at this web instance.
Now, we are asked what do we want to use in our public directory? That means which folder should the one containing all the files of the website to be hosted. If we hit enter a public folder will be automatically created for us.
Here we should type y (yes) to rewrite all the URL to index.html. And hit enter.
And you will see a public folder is created in addition to three other files. Now what we need to do is cut all our websites' files and shift them to the public folder.
All the files associated with our website should be in the public folder.
Now, we have one last command to run 'firebase deploy' (you can copy from the firebase website).
After the command executes and all our files get pushed to firebase hosting which will take a minute or two, we will be given a URL to the project console and website.
Now we can click the hosting URL, and we will see our website on the internet.
Similar Reads
Hosting Flutter Website On Firebase For Free
Flutter is a user interface development software development kit. Flutter is an open-source project maintained by Google. It enables software developers to make beautiful natively compiled applications for IOS, Android, Web, and Desktop with a single code base. Although developing flutter applicatio
4 min read
How to Host a Website on GitHub For Free?
GitHub is not only a platform for version control and code management but also a great tool for hosting websites for free. Whether you want to host a personal blog, a project portfolio, or just showcase your work, GitHub Pages offers a simple way to publish a static website directly from a GitHub re
5 min read
Password Protect a Static Website
Static websites are on rising again, In the early days of Internet HTML, CSS with some JavaScript is all the website, since then a number of Backend Frameworks like Django, Larvel, Ruby on Rails have been developed along with looks like WordPress which now powers one-third of websites have been also
6 min read
What is Rollback in Firebase Hosting?
Firebase Hosting is a robust application that enables developers to upload and launch their applications effectively and securely. Another great feature used in Firebase Hosting is the ability to rollback which means that if anything goes wrong with the application that has been hosted. In this arti
4 min read
Hosting Your Django Website on a CentOS VPS
Hosting any website/web application on a live server can sometimes become difficult if proper steps are not taken while deploying it. There are mainly 3 different types of hosting: Shared Hosting - Usually used for small (single page) websites with limited traffic.VPS Hosting - VPS ( Virtual Private
5 min read
How to Use Hosting Console in Firebase?
For developers, Firebase Hosting offers production-quality online content hosting. You may easily launch web applications and send both static and dynamic content to a global CDN with a single command (content delivery network). You can host your app's static assets (HTML, CSS, JavaScript, media fil
3 min read
Best NodeJS Free Hosting Services
To deploy web apps, we require hosting services, particularly with the widely used JavaScript runtime environment known as NodeJS. For developers who want to handle projects without investing money to test apps or learn new technologies, free hosting is very helpful. These are a few of the top free
4 min read
How to Publish a Static Website on GitHub?
Publishing a static website on GitHub is a great way to share your work with the world. GitHub Pages is a service offered by GitHub that allows you to host your static websites directly from a GitHub repository. In this article, weâll walk you through the steps to publish your static website on GitH
6 min read
How to Deploy a Basic Static HTML Website to Heroku?
Heroku is a simple and one-stop solution to host any website or server. This article revolves around how you can host your own Static HTML webpage on Heroku. To demonstrate this we are going to build a simple webpage and host it. PrerequisitesGitHeroku AccountHeroku CLI Let's create a directory name
3 min read
Connecting Custom Domain To Website Hosted On Firebase
Firebase is one of the best platforms to host a static website for free. When we have a website hosted on firebase we get two domains assigned to it. For example, the project id for my portfolio website which is already hosted on firebase is 'ankit-kumar-cv' therefore the URLs assigned to it were: p
4 min read