You're viewing the legacy docs. They are deprecated as of May 18, 2016.
Go to current docs

Hosting Guide

Deploying Your Site

Firebase Hosting gives you a fast, secure and reliable way to host your app's static assets such as HTML, CSS, JavaScript, and media files. Our production-grade hosting is backed by a global CDN, serves content over SSL by default, and is available either on your own custom domain or on a subdomain of firebaseapp.com.

Getting Started

To get started with Firebase Hosting, log in to your Account Dashboard, select the Firebase app you want to add hosting to and select the Set Up Hosting link on the Dashboard. Once you deploy your project, this is where you'll be able to see a history of your deploys, roll back to a previous deploy, and set up a custom domain.

Next, we'll install the Firebase CLI (command line tool) and initialize your site.

Setting up the Firebase Command Line Tool

First Time Installation

The Firebase command line tools require Node.js and npm, which can both be installed by following the instructions on https://nodejs.org/. Installing Node.js also installs npm.

The Firebase command line tools require Node.js version 0.10.0 or greater.

Once you have Node.js and npm installed, you can install the Firebase command line tools via npm:

$ npm install -g firebase-tools

# or use sudo (with caution) if required by your system permissions
# sudo npm install -g firebase-tools

This installs the globally available firebase command.

Updating Previously Installed Firebase Tools

If you have a previously installed version of Firebase command line tools, you can easily update them to the latest version:

$ npm update -g firebase-tools

# or use sudo (with caution) if required by your system permissions
# sudo npm update -g firebase-tools

Initializing Your Site

If you have an existing Firebase project you'd like to deploy, cd to the project's root directory and run:

$ firebase init

Deploying Your Site

To deploy your site, simply run the following command from your project directory:

$ firebase deploy

This will deploy your project to <YOUR-FIREBASE-APP>.firebaseapp.com. In the next section, we'll walk through using a custom domain with Firebase Hosting.

SSL Only

Firebase Hosting is SSL-only, meaning that content will only be served over HTTPS. As you are developing your application make sure that all external resources not hosted on Firebase Hosting are loaded over SSL (HTTPS), including any external scripts. Most browsers do not allow users to load "mixed content" (SSL and non-SSL traffic).

The firebase.json File

The firebase init command creates a firebase.json settings file in the root of your project's directory. This required file is used to configure which files are published upon deployment. Your default firebase.json file will look like this:

{
  "firebase": "myfirebase",
  "public": "app",
  "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
  ]
}

The file's three default properties - firebase, public, and ignore - are described in detail below.

firebase

"firebase": "myfirebase"

required - The firebase setting contains the name of the Firebase app to which your project will be linked. The app name appears in URL used to access your Firebase database (e.g. https://.firebaseio.com). It will also be used as the subdomain on firebaseapp.com. The logged in user must have access to that Firebase app in order to deploy.

public

"public": "app"

required - The public setting tells the firebase command which directory to upload to Firebase Hosting. This directory must be inside the project directory and must exist. The default value is the project's root directory.

ignore

"ignore": [
  "firebase.json",
  "**/.*",
  "**/node_modules/**"
]

optional - The ignore setting is an optional parameter since v1.0.1 of firebase-tools that specifies files to ignore on deploy. It can take glob definitions the same way Git handles .gitignore.