How to deploy your website using Firebase
Building a website is always a huge task, especially for beginners who just started to dive into programming space. What more exciting can be to showcase your website for everyone to see online.
Firebase Hosting is an excellent choice for hosting your website, offering reliability, scalability, and a straightforward deployment process. In this guide, I’ll walk you through the steps to deploy your website using Firebase Hosting.
Prerequisites
- A Gmail Account for firebase
- NodeJS Installed on your computer
- Basic understanding of NodeJS and Programming
Step 1: Sign Up for Firebase
If you don’t already have a Firebase account, you’ll need to sign up. You can use your Google account to log in or create a new Firebase-specific account. Once you’re logged in, access the Firebase Console.
Step 2: Create a New Project
In the Firebase Console, click on “Add Project” to create a new project. Give your project a name, and you can choose to enable Google Analytics if you wish. Click “Create Project” to proceed.
Step 3: Install Firebase CLI
To interact with Firebase from your local machine, you’ll need the Firebase Command Line Interface (CLI). If you haven’t already installed it, open your terminal and run:
npm install -g firebase-tools
Step 4: Initialize Your Firebase Project
In your project directory, open your terminal and run:
firebase login
This command will open a browser window, allowing you to log in to Firebase using the same account you used in step 1.
After logging in, navigate to your project directory and run:
firebase init
This command will guide you through the initialization process. Choose “Hosting” from the options presented and select your project from the list. You can specify your website’s public directory (usually “public”), You can move your website files on to the public to let firebase take up your index.html (Select No when prompted to replace the found index.html) and whether you want to configure it as a single-page app.
Step 5: Deploy Your Website
Now that your project is initialized, it’s time to deploy your website. In your terminal, run:
firebase deploy
Firebase will begin deploying your website to its hosting servers. Once the process is complete, Firebase will provide you with a Hosting URL where your website is now live.
Step 6: Configure Domain (Optional)
If you have a custom domain, you can configure it to point to your Firebase Hosting. In the Firebase Console, go to “Hosting,” and under the “Custom Domains” tab, Add the domain address and add a new record in the DNS with the hosting and value provided by Firebase as type TXT in the DNS Management from where you have bought the domain.