Firebase / Firebase Hosting

Getting Started with Firebase Hosting

This tutorial will guide you through the process of setting up Firebase Hosting for the first time. You'll learn how to initialize your project, deploy your app, and view it live …

Tutorial 1 of 5 5 resources in this section

Section overview

5 resources

Covers deploying web applications with Firebase Hosting, including security and domain management.

Introduction

In this tutorial, you will learn how to use Firebase Hosting to host your web applications. Firebase Hosting provides fast and secure web hosting for your static and dynamic content. At the end of this tutorial, you will have a live web app that is deployed on Firebase Hosting.

Learning Outcomes:
- Initialize a Firebase project
- Deploy a web app to Firebase Hosting
- View your live web app on Firebase Hosting

Prerequisites:
- Basic understanding of web development (HTML, CSS, JavaScript)
- Node.js and npm installed on your local development machine
- A Firebase account

Step-by-Step Guide

1. Install Firebase CLI

Firebase CLI (Command Line Interface) allows you to interact with Firebase from your terminal. Install it by running the following command in your terminal:

npm install -g firebase-tools

2. Login to Firebase

After installing the Firebase CLI, you need to log in to your Firebase account. In your terminal, run:

firebase login

A browser window will open for you to log in to your Firebase account. After login, return to the terminal.

3. Initialize Your Firebase Project

Navigate to your project's directory and run:

firebase init

Follow the prompts. Select 'Hosting', then choose an existing project or create a new one. For the public directory, input the directory that holds your web app's production build (usually build, public, or dist).

4. Deploy Your Web App

After initializing your Firebase project, you can deploy your app with:

firebase deploy

Your web app is now live on Firebase Hosting!

Code Examples

Code Example 1: Initialize Firebase Project

cd my-web-app # Navigate to your project directory
firebase init # Initialize your Firebase project
  • cd my-web-app changes your current directory to your project directory.
  • firebase init initializes your Firebase project.

Code Example 2: Deploy Your Web App

firebase deploy # Deploy your web app
  • firebase deploy deploys your web app.

Summary

In this tutorial, we have covered how to initialize a Firebase project, deploy a web app to Firebase Hosting, and view your live web app. Keep practicing by deploying different web apps or explore more Firebase features.

Practice Exercises

Exercise 1: Initialize and deploy a simple "Hello World" web app.
Solution 1: Create a new directory, initialize a Firebase project, create an index.html file with "Hello World", and deploy it.

Exercise 2: Deploy a web app that includes CSS and JavaScript files.
Solution 2: Create a new directory, initialize a Firebase project, create index.html, styles.css, and script.js files, and deploy it.

Exercise 3: Update your deployed web app.
Solution 3: Make changes to your web app, then run firebase deploy again to update it.

Remember, practice is key when learning new tools and technologies. Happy coding!

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

HTML

Learn the fundamental building blocks of the web using HTML.

Explore

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

PDF Password Protector

Add or remove passwords from PDF files.

Use tool

Color Palette Generator

Generate color palettes from images.

Use tool

Text Diff Checker

Compare two pieces of text to find differences.

Use tool

Percentage Calculator

Easily calculate percentages, discounts, and more.

Use tool

JSON Formatter & Validator

Beautify, minify, and validate JSON data.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help