What is Firebase Hosting?

Firebase hosting is a Google hosting service which provides static web content to the user in a secure, fast, free and easy way.

Why Firebase Hosting?

Most of the web hosting will charge you or will be slow if they are free, also you have to pay extra for getting an SSL certificate to convert your website to a secure one with https.

Firebase hosting is free. So, it won’t cost you anymore. It by default provides SSL certificate and offers an impressive speed across multiple geographic locations without the need for a separate CDN on top.

Requirements

I believe you might already have a Gmail account, which is enough. If not create one.

Before you can install the Firebase CLI, you will need to install Node.js on your machine.

Once you’ve installed NodeJs, you can install the Firebase CLI using npm (the Node Package Manager) by running the following command:

npm install -g firebase-tools

This is optional. There are various domain name providers in the world. Additionally, you can buy one from Godaddy.

Lets get our hands dirty

Step 1: Creating firebase project

Go to firebase and sign in with your Google account


then create new project, enter your project name (firebase-demo in my case)


Step 2: Firebase Login

Now come back to the command line and go to your project folder

cd firebase-demo

First we have to login into firebase from command line. Type in the following command.

firebase login

It will take you to the sign-in page in the browser, once you’ve successfully logged in it will show you something like this


Image for post


on command line

Step 3: Initializing project

To initialize firebase project you have to enter the command

firebase init

Then you have to select Hosting feature and click enter


Image for post

Then it will ask you to select firebase project, select project which we created in step 1 (firebase-demo in my case)


Image for post

Then it will ask you enter the main folder in which all your website assets are present. (public folder in my case)


Image for post

It will ask you whether your application is single page or not, for now enter y


Image for post

It will try to override your index.html file, to avoid doing that enter n


Image for post

Step 4: Checking setup (optional )

If everything goes right you can check you website locally by running command

firebase serve

It will run you website locally on http://localhost:5000 by default.


Image for post

Step 5: Deployment

For deployment of your project you have to run command

firebase deploy

Comments

Popular posts from this blog

Flutter : Introduction

Dart: Functions

Firebase Cloud Messaging