Advertisement

Before moving into the topic How to host your website in firebase, let me explain what is Firebase.

Firebase is a web and Mobile application development platform provides Backend as a Service (BaaS) now owned by Google.Firebase can be used for Authenticating users.You might have seen in many apps login with FB or Google+ or some other popular services.,It is also used as the database as a service for storing and retrieving data given by users, static websites can be hosted over firebase, notifications can be sent to users via firebase.In order to use firebase, you don’t need to learn any specific programming language.You can simply call the API and it works for iOS, Android and for web applications it can be integrated with JavaScript.

Firebase API’s can be integrated with Swift, Java,objective-c, JavaScript,C++, Unity.It works flawlessly and does jobs what you command.With the help of firebase, one can develop excellent applications.The data’s provided by firebase were real time.Real-time in the sense updates frequently.

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

Node.js was developed by Google to make javascript as a backend framework.In firebase, it was used to upload and update file for our tasks (such as hosting a site, making database rules,etc.,).

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.

ALSO READ  The tech behind Google Assistants Mm-hmm

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

firebase login

It will take you to the browser to authenticate your firebase account.Use the same Gmail which is used for creating the project.

firebase init

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.