Get started with Firebase Hosting

Firebase Hosting gives you a fast, secure, and reliable way to host your app's static assets (HTML, CSS, JavaScript, media files, etc.) as well as to serve dynamic content and host microservices. Our production-grade hosting is backed by a global content delivery network (CDN). Hosting serves your content over SSL, by default, and can be used with your own custom domain or on a subdomain of firebaseapp.com.

To use Firebase Hosting, make sure that you've created a Firebase project and completed the "Get Started" wizard on your Firebase project's Hosting page.

Install the Firebase CLI

The Firebase CLI (command line interface) requires Node.js and npm (the Node Package Manager).

  1. Install Node.js using one of the following options. Installing Node.js automatically installs npm.

    • For Mac/Linux, use nvm (the Node Version Manager).
    • For Windows, use nvm-windows.
  2. Install the Firebase CLI using npm by running:

    npm install -g firebase-tools

    This command installs the globally available firebase command. To update to the latest version of the Firebase CLI, re-run the same npm install command.

  3. Sign into Firebase using your Google account by running:

    firebase login

    This command connects your local machine to Firebase and grants you access to your Firebase projects.

  4. To test that authentication worked (and to list all of your Firebase projects), run the following command:

    firebase list

    The displayed list should be the same as the Firebase projects listed in the Firebase console.

Update to the latest CLI version

Make sure that you're using the most up-to-date Firebase CLI version by re-running the CLI installation command:

npm install -g firebase-tools

Access your Firebase projects

To connect your local machine to your Firebase account and obtain access to your Firebase projects, run the following command:

firebase login

Initialize your site

From the root of your project directory, run the following command:

firebase init

Running the firebase init command creates a firebase.json configuration file in the root of your project directory. You can learn more about this file in the configure hosting behavior section of this guide.

Select a public root directory

When you initialize your site, you are prompted for a directory to use as the public root (default is "public"). If you don't already have a valid index.html file in your public root directory, one is created for you.

Deploy your site

To deploy your site, run the following command from your project's root directory:

firebase deploy

Your content will be deployed to your Firebase project's default Hosting site, your-firebase-project-id.firebaseapp.com.

Next steps

Now your site is ready to share with the world! You can also learn how to:

Also, take a look at the full documentation for the Firebase CLI.

Оставить отзыв о...

Текущей странице
Нужна помощь? Обратитесь в службу поддержки.