firebase-hosting-basics

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

hosting-basics

托管基础

This skill provides instructions and references for working with Firebase Hosting, a fast and secure hosting service for your web app, static and dynamic content, and microservices.
本Skill提供了使用Firebase Hosting的操作指南和参考资料,Firebase Hosting是一项为你的网页应用、静态和动态内容以及微服务提供的快速且安全的托管服务。

Overview

概述

Firebase Hosting provides production-grade web content hosting for developers. With a single command, you can deploy web apps and serve both static and dynamic content to a global CDN (content delivery network).
Key Features:
  • Fast Content Delivery: Files are cached on SSDs at CDN edges around the world.
  • Secure by Default: Zero-configuration SSL is built-in.
  • Preview Channels: View and test changes on temporary preview URLs before deploying live.
  • GitHub Integration: Automate previews and deploys with GitHub Actions.
  • Dynamic Content: Serve dynamic content and microservices using Cloud Functions or Cloud Run.
Firebase Hosting为开发者提供生产级别的网页内容托管服务。只需一条命令,你即可部署网页应用,并通过全球内容分发网络(CDN)提供静态和动态内容。
核心特性:
  • 快速内容分发: 文件会缓存于全球各地CDN节点的SSD存储中。
  • 默认安全: 内置零配置SSL。
  • 预览通道: 在正式部署前,可通过临时预览URL查看和测试更改。
  • GitHub集成: 借助GitHub Actions自动化预览和部署流程。
  • 动态内容: 可使用Cloud Functions或Cloud Run提供动态内容和微服务。

Hosting vs App Hosting

Hosting与App Hosting的对比

Choose Firebase Hosting if:
  • You are deploying a static site (HTML/CSS/JS).
  • You are deploying a simple SPA (React, Vue, etc. without SSR).
  • You want full control over the build and deploy process via CLI.
Choose Firebase App Hosting if:
  • You are using a supported full-stack framework like Next.js or Angular.
  • You need Server-Side Rendering (SSR) or ISR.
  • You want an automated "git push to deploy" workflow with zero configuration.
选择Firebase Hosting的场景:
  • 你需要部署静态网站(HTML/CSS/JS)。
  • 你需要部署简单的单页应用(React、Vue等,无SSR)。
  • 你希望通过CLI完全掌控构建和部署流程。
选择Firebase App Hosting的场景:
  • 你使用受支持的全栈框架,如Next.js或Angular。
  • 你需要服务端渲染(SSR)或增量静态再生(ISR)。
  • 你希望实现无需配置的“git push即可部署”自动化工作流。

Instructions

操作指南

1. Configuration (
firebase.json
)

1. 配置(
firebase.json

For details on configuring Hosting behavior, including public directories, redirects, rewrites, and headers, see configuration.md.
如需了解配置Hosting行为的详细信息,包括公共目录、重定向、重写和请求头,请参阅configuration.md

2. Deploying

2. 部署

For instructions on deploying your site, using preview channels, and managing releases, see deploying.md.
如需了解部署网站、使用预览通道以及管理版本的操作指南,请参阅deploying.md

3. Emulation

3. 本地模拟

To test your app locally:
bash
firebase emulators:start --only hosting
This serves your app at
http://localhost:5000
by default.
要在本地测试你的应用:
bash
firebase emulators:start --only hosting
默认情况下,应用将在
http://localhost:5000
提供服务。