{"id":20591,"date":"2021-09-13T12:52:38","date_gmt":"2021-09-13T12:52:38","guid":{"rendered":"https:\/\/www.bacancytechnology.com\/blog\/?p=20591"},"modified":"2025-03-05T07:07:13","modified_gmt":"2025-03-05T07:07:13","slug":"deploy-angular-12-application-using-firebase-hosting","status":"publish","type":"post","link":"https:\/\/www.bacancytechnology.com\/blog\/deploy-angular-12-application-using-firebase-hosting","title":{"rendered":"How to Deploy Angular 12 Application Using Firebase Hosting?"},"content":{"rendered":"<p>There are a number of organizations providing free hosting of applications irrespective of their size. Each of them provides different features and functions. One of them is Firebase, which can store your hosting content upto 10GB and can store a 1GB real-time database, and 10GB\/month can be downloaded. For more details, you can check out this <a href=\"https:\/\/firebase.google.com\/pricing\" target=\"_blank\" rel=\"noopener\">page<\/a>.<\/p>\n<h2>Overview<\/h2>\n<p>Today, in this tutorial, we will be learning how painless it is to <b>deploy an Angular 12 application<\/b> on Firebase using its Firebase hosting feature. <\/p>\n<h2>Prerequisites<\/h2>\n<p>Node and Angular CLI are already installed.<\/p>\n<p>I assume you have already created your angular application. If not, you can create a new project using the following command: <\/p>\n<pre>ng new project-name<\/pre>\n<p>project-name is variable; the project that I have created is angular12-hosting.<\/p>\n<p>Well, we are ready with the project now. So let\u2019s follow the steps below to host our application.<\/p>\n<h2>Steps: Deploy the Angular 12 Application using Firebase Hosting<\/h2>\n<p>To begin with, Go to your project directory and open the command prompt\/terminal.<\/p>\n<p>Now, we need to create a build for our project. So run the following command: <\/p>\n<pre>ng build<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-Hosting-1.jpg\" alt=\"Angular 12 Hosting\" width=\"598\" height=\"192\" class=\"aligncenter size-full wp-image-20628\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-Hosting-1.jpg 598w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-Hosting-1-300x96.jpg 300w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/p>\n<p>After successful completion of the build, make sure the dist folder has been created in your project.<\/p>\n<p>The next thing to do is to create a project in the firebase. Go to the <a href=\"https:\/\/console.firebase.google.com\/\" target=\"_blank\" rel=\"noopener\">Firebase console<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase-Console.jpg\" alt=\"Firebase Console\" width=\"1099\" height=\"520\" class=\"aligncenter size-full wp-image-20599\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase-Console.jpg 1099w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase-Console-300x142.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase-Console-1024x485.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase-Console-768x363.jpg 768w\" sizes=\"auto, (max-width: 1099px) 100vw, 1099px\" \/><\/p>\n<p>Click on the create a project button, and it will ask you to insert a project name.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/firebase-project-name-is-angular12-hosting.jpg\" alt=\"firebase project name is angular12-hosting\" width=\"1099\" height=\"566\" class=\"aligncenter size-full wp-image-20600\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/firebase-project-name-is-angular12-hosting.jpg 1099w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/firebase-project-name-is-angular12-hosting-300x155.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/firebase-project-name-is-angular12-hosting-1024x527.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/firebase-project-name-is-angular12-hosting-768x396.jpg 768w\" sizes=\"auto, (max-width: 1099px) 100vw, 1099px\" \/><\/p>\n<p>My firebase project name is <b>angular12-hosting<\/b>; you can add yours. Then click Continue.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Create-a-Project.jpg\" alt=\"Create a Project\" width=\"1099\" height=\"566\" class=\"aligncenter size-full wp-image-20601\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Create-a-Project.jpg 1099w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Create-a-Project-300x155.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Create-a-Project-1024x527.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Create-a-Project-768x396.jpg 768w\" sizes=\"auto, (max-width: 1099px) 100vw, 1099px\" \/><\/p>\n<p>If you are using Google Analytics, then you can enable Google Analytics. Otherwise, make it disable and click on Create Project.<\/p>\n<p>After successfully creating the project in firebase, again go to the angular project directory in your file explorer, open the command prompt\/terminal, and install firebase tools using the following command. <\/p>\n<pre>npm i -g firebase-tools<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-Projects-min.jpg\" alt=\"Angular Projects\" width=\"594\" height=\"179\" class=\"aligncenter size-full wp-image-20629\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-Projects-min.jpg 594w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-Projects-min-300x90.jpg 300w\" sizes=\"auto, (max-width: 594px) 100vw, 594px\" \/><\/p>\n<p>To host the <a href=\"https:\/\/www.bacancytechnology.com\/blog\/new-features-in-angular-12\" target=\"_blank\" rel=\"noopener\">Angular 12<\/a> application on Firebase, we need to log into our firebase account using the following command. <\/p>\n<pre>firebase login<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Deploy-angular-12-hosting.jpg\" alt=\"Deploy angular 12 hosting\" width=\"508\" height=\"179\" class=\"aligncenter size-full wp-image-20630\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Deploy-angular-12-hosting.jpg 508w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Deploy-angular-12-hosting-300x106.jpg 300w\" sizes=\"auto, (max-width: 508px) 100vw, 508px\" \/><\/p>\n<p>It will ask you to choose your Gmail account and some permissions to use Firebase CLI. Please note that select the account on which you have created the firebase project and allow those permissions.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-app-with-firebase-hosting.jpg\" alt=\"Angular 12 app with firebase hosting\" width=\"511\" height=\"179\" class=\"aligncenter size-full wp-image-20631\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-app-with-firebase-hosting.jpg 511w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-app-with-firebase-hosting-300x105.jpg 300w\" sizes=\"auto, (max-width: 511px) 100vw, 511px\" \/><\/p>\n<p>After successful login, we need to initialize the firebase. To do so, run the following command. <\/p>\n<pre>firebase init<\/pre>\n<p>The Firebase initialization process consists of questions that we need to answer correctly for successful hosting. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase.jpg\" alt=\"Firebase\" width=\"844\" height=\"335\" class=\"aligncenter size-full wp-image-20632\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase.jpg 844w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase-300x119.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase-768x305.jpg 768w\" sizes=\"auto, (max-width: 844px) 100vw, 844px\" \/><\/p>\n<p>1. Are you ready to proceed? Enter Yes<\/p>\n<p>2. Which Firebase features do you want to set up for this directory? Select Hosting: Configure files <\/p>\n<p><em><strong>(Note that you can select multiple features too, but for now, we need only hosting. Also, make sure you need to  press the Space key to select a feature\/option, and then press Enter to confirm that.)<\/strong><\/em><\/p>\n<p>Now, they will ask to select the project directory.<\/p>\n<p>3. Please select an option: Select <em><b>Use an existing project<\/b><\/em> (if you have already created a project in firebase. If not, you can choose Create a new project)<br \/>\n4. Select your project; mine was angular12-hosting. So I have selected that by pressing enter.<\/p>\n<p>After that, make sure what\u2019s your public directory of an angular project. You can check by going to the dist folder.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-app-min.jpg\" alt=\"Angular 12 app \" width=\"1099\" height=\"335\" class=\"aligncenter size-full wp-image-20633\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-app-min.jpg 1099w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-app-min-300x91.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-app-min-1024x312.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-app-min-768x234.jpg 768w\" sizes=\"auto, (max-width: 1099px) 100vw, 1099px\" \/><\/p>\n<p>The directory of my project is dist\/angular12-hosting.<\/p>\n<p>The next question about firebase initialization will be to add enter our directory. I am adding mine; please enter as per your project.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase-hosting.jpg\" alt=\"Firebase hosting\" width=\"847\" height=\"499\" class=\"aligncenter size-full wp-image-20634\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase-hosting.jpg 847w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase-hosting-300x177.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Firebase-hosting-768x452.jpg 768w\" sizes=\"auto, (max-width: 847px) 100vw, 847px\" \/><\/p>\n<p>5. What do you want to use as your public directory? Enter dist\/angular12-hosting<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-app-using-firebase.jpg\" alt=\"Angular 12 app using firebase\" width=\"538\" height=\"213\" class=\"aligncenter size-full wp-image-20635\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-app-using-firebase.jpg 538w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-app-using-firebase-300x119.jpg 300w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/p>\n<p>6. Configure as a single-page app? Enter <b>Yes<\/b><\/p>\n<p>7. Setup automatic builds and deploys with Github? Enter <b>No<\/b> <em>(if you want to set up with github, you can enter Yes)<\/em><\/p>\n<p>8. File dist\/**\/index.html already exists? Overwrite? Enter <b>No<\/b><\/p>\n<p>Firebase will create some of the files.<\/p>\n<p><em>And finally, Firebase initialization completes.<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/GIF-4.gif\" alt=\"Firebase initialization completes\" width=\"320\" height=\"320\" class=\"aligncenter size-full wp-image-20620\" \/><\/p>\n<p>Now we are ready with setups. Run the following command to deploy our project.<\/p>\n<pre>firebase deploy<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Deploy-angular-12-app.jpg\" alt=\"Deploy angular 12 app\" width=\"528\" height=\"81\" class=\"aligncenter size-full wp-image-20636\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Deploy-angular-12-app.jpg 528w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Deploy-angular-12-app-300x46.jpg 300w\" sizes=\"auto, (max-width: 528px) 100vw, 528px\" \/><\/p>\n<p>After completing the deploying process, firebase will give you a URL to deploy the Angular 12 application using Firebase hosting feature.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-application-min-1.jpg\" alt=\"Angular 12 application \" width=\"598\" height=\"267\" class=\"aligncenter size-full wp-image-20637\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-application-min-1.jpg 598w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-application-min-1-300x134.jpg 300w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/p>\n<p>Go to the browser and run this Hosting URL.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-hosting-app-running.jpg\" alt=\"Angular 12 hosting app running\" width=\"1100\" height=\"552\" class=\"aligncenter size-full wp-image-20611\" srcset=\"https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-hosting-app-running.jpg 1100w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-hosting-app-running-300x151.jpg 300w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-hosting-app-running-1024x514.jpg 1024w, https:\/\/www.bacancytechnology.com\/blog\/wp-content\/uploads\/2021\/09\/Angular-12-hosting-app-running-768x385.jpg 768w\" sizes=\"auto, (max-width: 1100px) 100vw, 1100px\" \/><\/p>\n<p>My application is running successfully!<\/p>\n<p>My application is running on this <a href=\"https:\/\/angular12-hosting.web.app\" target=\"_blank\" rel=\"noopener\">URL<\/a>. <\/p>\n<p>Quick Read:<br \/>\n<a href=\"https:\/\/www.bacancytechnology.com\/blog\/angular-best-practices\" target=\"_blank\" rel=\"noopener\">Best Practices to Organize Your Angular App<\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>So, this was about how to deploy the Angular 12 application using Firebase hosting. I hope the tutorial was helpful and that you tried to host your application as well. If you have any questions, feel free to connect. Are you an enthusiastic learner who likes to explore more about Angular? Then, visit the <a href=\"https:\/\/www.bacancytechnology.com\/tutorials\/angularjs\" target=\"_blank\" rel=\"noopener\">Angular Tutorials page<\/a> and get your hands on Angular. We will provide you github repository as well so that you can clone the repository and play around with the code. <\/p>\n<p>If you are looking for skilled, dedicated, and experienced developers for your Angular project, connect with us to <a href=\"https:\/\/www.bacancytechnology.com\/angular-js-development\" target=\"_blank\" rel=\"noopener\">hire Angular developer<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are a number of organizations providing free hosting of applications irrespective of their size. Each of them provides different features and functions. One of them is Firebase, which can store your hosting content upto 10GB and can store a 1GB real-time database, and 10GB\/month can be downloaded. For more details, you can check out [&hellip;]<\/p>\n","protected":false},"author":146,"featured_media":20593,"comment_status":"open","ping_status":"open","sticky":false,"template":"blog-new-template.php","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"_lmt_disableupdate":"no","_lmt_disable":"","footnotes":""},"categories":[989],"tags":[],"coauthors":[2427],"class_list":["post-20591","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-angularjs"],"acf":[],"modified_by":"Binal Prajapati","_links":{"self":[{"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/posts\/20591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/users\/146"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=20591"}],"version-history":[{"count":0,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/posts\/20591\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/media\/20593"}],"wp:attachment":[{"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=20591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=20591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=20591"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/blog\/wp-json\/wp\/v2\/coauthors?post=20591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}