Enable HTTPS in Firebase Hosting: install the Firebase CLI, log in, initialize and deploy your project, and secure custom domains with free SSL certificates.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
Step 1: Install Firebase CLI
First, you need to install the Firebase CLI on your machine. If you haven't already, follow the instructions below to install the CLI.
Open your terminal and run the following command to install Firebase CLI globally using npm (Node Package Manager):
npm install -g firebase-tools
This command will ensure you have access to all Firebase CLI commands from any directory.
Step 2: Log in to Firebase
Before you can use Firebase services, you need to log in using the Firebase CLI. Execute the following command in your terminal:
firebase login
This command will open your browser and prompt you to log in to your Google account. Make sure you use the account associated with your Firebase projects.
Step 3: Initialize Firebase Hosting
Navigate to your project directory using the terminal. If you don't have a project yet, create a new directory and navigate into it.
Next, run the following command to initialize your Firebase project:
firebase init
You'll be prompted to select the Firebase features you want to set up. Use your arrow keys to navigate to "Hosting" and select it by pressing the space bar, then press enter to confirm your choice.
Continue through the setup prompts. You'll be asked a series of questions about your project:
Select a Firebase project: Choose an existing Firebase project or create a new one. it's important to host under a project's domain for obtaining an SSL certificate.
What do you want to use as your public directory? Specify the directory that contains your static files (usually public).
Configure as a single-page app? Choose yes if you're deploying a single-page application (like those built with React, Angular, or Vue.js). Choose no if your app has multiple entry points.
Step 4: Deploy Your Application
Now that your Firebase Hosting configuration is set, you're ready to deploy your application. To do this, run the following command:
firebase deploy
Firebase CLI will upload your files to the Firebase servers, and they'll be hosted at https://<your-project-id>.firebaseapp.com.
Step 5: Enable HTTPS
Firebase Hosting automatically provides a free SSL certificate for your custom domain, ensuring your project uses HTTPS out-of-the-box if you're using the firebaseapp.com subdomain.
If you're using a custom domain, you need to add it to your Firebase Hosting setup. Follow these steps to enable HTTPS for a custom domain:
Firebase will automatically provision and renew SSL certificates for any custom domain you add. After setting up your domain, it may take a few minutes for the HTTPS to be active.
That's it! Your Firebase Hosting project is now accessible over HTTPS.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.