attheoaks.com

Effortlessly Host Your Angular App on Google Firebase

Written on

Creating Your Angular Application

In this guide, I will walk you through the process of hosting your Angular application on Google Firebase. After spending time developing an engaging Angular app that functions smoothly on your local system, you might be eager to showcase it to a global audience. Whether you're enhancing your portfolio for potential employers or planning to monetize your application, Firebase offers a simple and efficient hosting solution. I'll guide you step-by-step, from setting up a basic Angular application to deploying it for public access via Firebase.

Getting Started with Your Angular Project

For this demonstration, we'll utilize Angular 13 on a Windows 10 setup. To initiate a new Angular project, you can run the following command in your command prompt. In our case, we'll name the project angular-firebase-hello-world, but feel free to choose any name you prefer.

ng new angular-firebase-hello-world

Next, navigate to your app.component.html file located in the srcapp directory, and replace all the default content with the following:

<h1>Angular Firebase Hello World</h1>

To verify that this simple application runs correctly, execute the command:

ng serve

Once the application compiles without errors, you can open a web browser and visit the URL http://localhost:4200. You should see a page resembling the one shown below:

Simple Angular Application Example

Building Your Angular Project

Now that you have a basic application ready, the next step is to build it for deployment. In your command prompt, execute:

ng build

Upon successful completion, your command prompt will display a message confirming that the build was successful.

Successful Build Confirmation

Creating a Firebase Project

Navigate to Firebase Console

Afterward, select the "Add Project" option.

Adding a New Project

You will then be directed to a setup wizard where you need to enter your Project Name. For our example, we will use "Angular-Firebase-Hello-World".

Project Name Input

The next screen will prompt you to enable Google Analytics for your project. The default option is "Yes," so you can proceed by clicking the Continue button. On the final setup page, choose to use an existing Google Analytics account or create a new one, and then click the Create Project button to complete the setup.

Google Analytics Setup

Installing Firebase Tools Locally and Logging In

After your Firebase project is created, return to your command prompt to install Firebase tools using the following command:

npm install -g firebase-tools

Next, log in to Firebase CLI with:

firebase login

You will be prompted to choose a Google account for authentication. Once logged in successfully, you should see a confirmation message in your command line.

Initializing Your Firebase Project

With successful authentication, it's time to initialize your project as a Firebase project. In your project directory, type the command:

firebase init

Follow the prompts in the setup wizard. When asked if you are ready to proceed, respond with "Yes" or "Y". Then select the hosting feature by pressing the spacebar and hitting Enter.

Selecting Firebase Features

You will then associate your project directory with the Firebase project you created earlier. Choose "Use an existing project" and select your project, "Angular-Firebase-Hello-World."

Selecting Existing Project

Specify the public directory as distangular-firebase-hello-world. For the prompt about configuring as a single-page app, select "No". Similarly, respond "No" to the prompts regarding automatic builds with GitHub and overwriting existing files.

Public Directory Configuration

Completing the Firebase Initialization

After completing all prompts, you will see a message indicating that Firebase initialization is complete.

Firebase Initialization Completion

Deploying Your Application to Firebase

The final step is to deploy your application. Type the following command in your command prompt:

firebase deploy

Deployment Success Confirmation

Accessing Your Application

Now, open your web browser and navigate to the provided URL to see your application live on Firebase.

Live Application on Firebase

Conclusion

Thank you for reading this guide! I hope you found it helpful. If you have any questions or feedback, feel free to reach out. If you enjoyed this article, consider signing up for Medium through my referral link for unlimited access to my articles and thousands of others from talented writers.

This first video provides a detailed step-by-step guide on deploying an Angular app to Firebase.

The second video offers a comprehensive tutorial on deploying your Angular application using Firebase Hosting.

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

The Evolving Landscape of Corporate Social Responsibility (CSR)

Explore the dynamics of Corporate Social Responsibility (CSR), the factors influencing it, and how businesses can adapt for ethical accountability.

Understanding the Connection Between Self-Esteem and Wealth

Explore how self-esteem impacts financial success and discover ways to enhance your self-worth for a prosperous life.

Your Mind Shapes Your Life: Break Free from Boredom

Discover how your mindset shapes your reality and learn to harness the power of your subconscious to create a fulfilling life.