Getting started with Firebase Hosting

Step to step tutorial for 'How to get started with Firebase Hosting?'

July 22, 2017 - 2 minute read -
cli tutorial firebase

Introduction

Firebase is a mobile and web application development platform. It is owned by Google. Firebase provides below services/features -

Services/Features

  • Analytics
  • Authentication
  • Database
  • Storage
  • Hosting
  • Functions (Cloud functions)
  • Test Lab
  • Crash Reporting
  • Performance
  • Notifications (Firebase Cloud Messaging - FCM)
  • Remote configs
  • Dynamic Links
  • AdMob

Lets take a look on “Hosting” service provided by firebase.

Hosting

Firebase Hosting is very easy to use and anyone can deploy and see a static website working in 4 simple steps - Login to firebase, Add project, Initialize project and Deploy.

Login to firebase

Add Project

  • Click “Add Project”

  • Enter Project Name e.g. “MyFirstWebsite” and Country/Region e.g. “India”

  • And then “Create Project” button

Initialize project

  • Install Firebase CLI, Firebase CLI depends upon Node.j and npm. Install Nodejs which comes with npm. So, no need to install npm separately. Then firebase CLI, open command line interface/terminal of your OS and type -

    $ npm install -g firebase-tools
    
  • Initialize your website. cd to your local website project and type

    $ firebase init
    

    select type to “hosting”, press space and enter. select project “MyFirstWebsite” which you created on firebase and enter.

Deploy website

  • firebase init will create few files and directory in your project directory e.g. firebase.json and public.

  • Move all your website files(index.html, css, js etc) to public directory available at root of your website project directory.

  • At last in terminal type -

    $ firebase deploy
    
  • As soon as your code deploys you will see a sub-domain created for your website with firebase.com domain, may be something link -> myfirstwebsite.firebase.com.

  • If you want your own personal site and you can buy any domain and can always link that domain with your firebase project.

Firebase Hosting documentation