Firebase offers many services, including Firebase Hosting, which allows you to deploy your web application with ease and efficiency. In this shot, we will go through the steps for deploying a simple static HTML application on Firebase.
To create a new project:
Open the Firebase console.
Click “Add Project”.
Enter a project name, e.g., “New Project,” and click “Continue”. If you are signed into Firebase using an organization’s account (e.g. me@educative.io), then it will ask you to select the parent source for your project (which would be “educative,” in this case).
After a few moments, the Firebase project will be created! Click “Continue” to open the Firebase project overview.
Now, the Firebase project is ready to go. Next, we need to register our web application with Firebase. Let’s register our application:
</>
) to launch the setup workflow.Now, we need to add these Firebase SDK scripts to our application. In this shot, I am going to deploy this example-firebase-app. We need to copy and paste the code snippets at the bottom of the <body>
tag. For convenience, I have already added these in the index.html
file.
Firebase command-line interface (CLI) is used to interact with the Firebase web application. We will use it to interact with our application. Install Firebase CLI by entering the following command in the terminal opened in the app root directory:
npm install -g firebase-tools
It’s time to deploy your web application. This requires the following simple steps:
Open a terminal in the root directory of your app, and run the following command:
firebase login
Follow the instructions on the webpage to log in to Firebase, if you aren’t logged in already.
In the same terminal, run the following command:
firebase init
The result will be an interactive interface to configure the Firebase CLI.
When you’re asked which Firebase CLI features you want to set up, select the Hosting: “Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys”. Press Enter to confirm your selection.
abdulmonum/example-firebase-app
.index.html
file in the public directory is the same as the one in the repository. If there is a default Firebase-created index.html
file present, replace that with your index.html
file.firebase deploy
You’ll have the following output on your terminal.Congratulations! You have successfully deployed your first application on Firebase! Open the Hosting URL to view the website.