How to host a Node.js project on Firebase

Node.js is an open-source, cross-platform, server-side runtime environment for executing JavaScript code outside a web browser. It allows developers to use JavaScript for server-side scripting, which traditionally has been handled by languages like PHP, Java, and  Python.

Firebase is a mobile and web application development platform developed by Google. Firebase provides a suite of tools and services that can be used to build and deploy mobile and web applications quickly and easily. Firebase includes services for authentication, database management, hosting, cloud messaging, and more.

Steps to host a Node.js project on Firebase

  1. Sign up for a Firebase account here.

Sign up and install app
Sign up and install app
  1. Create a new Firebase project by clicking the "Create a Project" button on the Firebase console dashboard.

Create a project and click continue to step 3 of 3
Create a project and click continue to step 3 of 3

  1. Install the Firebase Command Line Interface (CLI) by entering npm install-g-firebase-tools.

npm install -g firebase-tools
Install Firebase
Install Firebase CLI from command prompt
Install Firebase CLI from command prompt
  1. Initialize the Firebase project. In the terminal or command prompt, navigate to the root directory of the Node.js project and run the firebase init command.

firebase init
Initialize Firebase

Initialize project
Initialize project
  1. Select "Firebase Hosting."

Select hosting from Build
Select hosting from Build
  1. Configure the Firebase Hosting settings.

Hosting configuration
Hosting configuration
  1. Deploy the project.

  2. Verify the deployment by visiting the URL of the Firebase Hosting site. We can find the URL of the site in the Firebase console under the "Hosting" tab. The Node.js project is now hosted on Firebase Hosting.

Free Resources