DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Build Full-Stack Web App With Firebase, Angular 15, React.js, Vue.js, and Blazor [Video]
  • 7 Best IDEs for AngularJS App Development
  • Login With Google in Angular Firebase Application
  • Leveraging Salesforce Using a Client Written In Angular

Trending

  • Breaking Bottlenecks: Applying the Theory of Constraints to Software Development
  • Google Cloud Document AI Basics
  • Unlocking AI Coding Assistants Part 3: Generating Diagrams, Open API Specs, And Test Data
  • Integrating Security as Code: A Necessity for DevSecOps
  1. DZone
  2. Coding
  3. Frameworks
  4. How to Deploy an Angular App on Firebase

How to Deploy an Angular App on Firebase

By 
Sanjay Saini user avatar
Sanjay Saini
·
Dec. 13, 19 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
26.0K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, I am going to share with you how you can deploy your Angular application on Firebase.

In case you don’t know what Firebase is, it’s a mobile and web application development and deployment platform. For more details, check out this link.

I have developed this simple frontend only (no backend) Todo App in Angular, which I am going to use to explain how simple it is to deploy your App in Firebase.

If you already have an app ready for deployment, you can follow along with me, as I am explaining these simple steps in this article.

Image title

Basic todo app

If you are interested in the source code of this app, you can get it from my GitHub repository link.


Create a Firebase Account

In order to deploy your app on Firebase, you must first need to have an account on the firebase website ( https://console.firebase.google.com).

The good news is that Firebase expects Google account for login, and I am sure you already have one. Otherwise, you can create one if you don’t have or you can create another Google account for Firebase if you don’t want to use an existing one.

Create a New Firebase Project

Once you are done with the account creation, now create your first Firebase project by clicking on the Add Project button. It’s a three-step process.

First, provide a unique name for your project. In my case, I have named it angular7-todo-app.

Second, enable Google analytics for this project, which is by default enabled so click on continue. Finally, configure the google analytics by selecting default account for firebase from the dropdown field and click on create project.

It will take 1-2 minutes to create the project, and that’s all you need to do on Firebase site for now in order to deploy this Todo App. Although you can do much more with Firebase, that’s not in scope for this article.

Image title

Creating Todo app in Firebase

Deploy App With Firebase Tool

Now we have all the setup needed at the Firebase site done, we are few steps away from the deployment of our app on Firebase.

Install Firebase Tools

We will require firebase tools installed on the machine for the deployment.

So open the command or bash window and navigate to your app project folder(in my case todo-app) and install firebase-tools on your machine via npm by running the following command:

npm install –g firebase-tools

Image title

Installing Firebase tools

Next, we need to login to Firebase from the command prompt/bash window by running following command:

firebase login --interactive

This will open the Firebase login in the browser for you to login so that we can work on our Firebase project from our machine using firebase tools CLI.

Image title

Firebase tools CLI

Configure Firebase Project Using Firebase-Tools

Now, in order to configure our Firebase project, we need to initialize the process in the project folder using following command:

firebase init

This will start a selection wizard with following steps in the console.

Step 1 —Select “Y” to proceed and then select the "Hosting: Configure and deploy Firebase Hosting sites" option since we want to only host our app at this moment.

Image title

Proceeding with "Y"


Image title

Hosting: Configure and deploy Firebase Hosting sites

Step 2 — Now, select "Use an existing project" option since we already created a Firebase project for this application.

Image title

Use an existing project

Step 3 — Next, select the newly created Firebase project, which, in my case is “angular7-todo-app.”

Image title

Selecting existing project

Step 4 – Type “No” to the "Configure as a single-page app" option since we will configure it by updating firebase.json file later on.

Image title

Not configuring application as SPA

The Firebase initialization wizard will create the following files in the project folder:


  • 404.html.
  • index.html.
  • .firebaserc.
  • Firebase.json.

Delete this index.html file since you might already have an index.html in your app project folder.

Now, edit this newly created firebase.json file and add the following configuration.

JSON
 




xxxxxxxxxx
1


 
1
"public": "docs",
2
"rewrites": [
3
    {
4
        "source": "**",
5
        "destination": "/index.html"
6
    }
7
],



Note: here public key value refers to the deployment folder for the App so make sure the outputPath value in the angular.json should be docs.

This setting will redirect the request to index.html page whenever the App is refreshed.

Image title

Checking outputPath value

Build the Angular App

Now, run the following commad on the command/bash window from your app project folder to generate distributable files in the docs folder:

ng build --prod

Image title

Building applciation


Deploy the App on Firebase

Finally, deploy the app by running following command on the command/bash window from your app project folder:

firebase deploy

Image title

Deploying the app to Firebase

Now, open the hosting URL in the browser, which in this case is https://angular7-todo-app.firebaseapp.com.

Image title

Final output


I hope you enjoyed this article! Please leave questions and/or comments below.

Firebase mobile app AngularJS

Opinions expressed by DZone contributors are their own.

Related

  • Build Full-Stack Web App With Firebase, Angular 15, React.js, Vue.js, and Blazor [Video]
  • 7 Best IDEs for AngularJS App Development
  • Login With Google in Angular Firebase Application
  • Leveraging Salesforce Using a Client Written In Angular

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!