使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Firebase Hosting
plat_web
主要功能
通过安全连接提供内容 |
Firebase Hosting 中内置了零配置的 SSL,因此始终能够确保安全地分发内容。
|
快速提供内容 |
您上传的每个文件均缓存在遍布世界各地的 CDN 边缘服务器的 SSD 上,并以 gzip 或 Brotli 的形式传送。我们会为您的内容自动选择最佳的压缩方法。无论您的用户身处何处,内容都可快速加载。
|
在上线前模拟甚至共享所做的更改 |
通过本地托管的网址查看和测试更改,并与模拟后端进行交互。
使用临时预览网址与团队成员共享更改。Hosting 还提供 GitHub 集成,以便轻松迭代预览的内容。
|
使用一个命令部署新版本 |
利用 Firebase CLI,您可以在短短几秒钟内启动并运行您的应用。利用命令行工具,您可以将部署目标添加到构建流程中。
如果您需要撤消部署,Hosting 可提供一键式回滚。
|
工作原理
无论您是在部署一个简单的应用着陆页,还是部署复杂的渐进式 Web 应用 (PWA),Hosting 均为您提供了专为部署和管理网站和应用而特别开发的基础架构、功能和工具。
使用 Firebase CLI,您可以从计算机上的本地目录将文件部署到我们的 Hosting 服务器。除了提供静态内容之外,您还可以使用 Cloud Functions for Firebase 或 Cloud Run 在您的网站上提供动态内容和托管微服务。所有内容都可从我们的全球级 CDN 上最近的边缘服务器通过 SSL 连接提供。
您还可以在上线前查看和测试更改。
使用 Firebase Local Emulator Suite,您可以通过本地托管的网址模拟您的应用和后端资源。您还可以使用临时预览网址共享更改,并设置 GitHub 集成,以便在开发期间轻松迭代。
Firebase Hosting 具有轻量级托管配置选项,支持您构建精密的 PWA。您可以轻松为客户端路由重新编写网址、设置自定义标头,甚至可以提供本地化的内容。
为了分发您的内容,Firebase 提供了多个网域和子网域选项:
默认情况下,每个 Firebase 项目在 web.app
和 firebaseapp.com
网域上都有免费的子网域。这两个网站提供相同的已部署内容和配置。
如果您拥有提供不同内容但仍共享相同 Firebase 项目资源的相关网站和应用(例如,如果您有博客、管理控制台和公开应用),则可以创建多个网站。
您可以将自己的域名关联到 Firebase 托管的网站。
Firebase 会自动为您的所有网域预配 SSL 证书,确保安全提供您的所有内容。
实现流程
|
安装 Firebase CLI |
有了 Firebase CLI,您可以轻松设置新 Hosting 项目、运行本地开发服务器以及部署内容。
|
|
设置项目目录 |
将静态资源添加到本地项目目录,然后运行 firebase init 将该目录与 Firebase 项目关联。
在本地项目目录中,您还可以为动态内容和微服务设置 Cloud Functions 或 Cloud Run。
|
|
在上线之前查看、测试并共享更改(可选) |
运行 firebase emulators:start 以通过本地托管的网址模拟 Hosting 和后端项目资源。
如需通过临时预览网址查看并共享更改,请运行 firebase hosting:channel:deploy 以创建预览渠道并向其实施部署。设置 GitHub 集成,以便轻松迭代预览的内容。
|
|
部署您的网站 |
当一切就绪时,运行 firebase deploy 即可将最新的快照上传到我们的服务器。如果您需要撤消部署,只需在 Firebase 控制台中执行一键式回滚。
|
|
关联到 Firebase Web 应用(可选) |
通过将您的网站关联到 Firebase Web 应用,您可以使用 Google Analytics 收集应用的使用情况和行为数据,还可以使用 Firebase Performance Monitoring 深入了解应用的性能特征。
|
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-08。
[null,null,["最后更新时间 (UTC):2025-08-08。"],[],[],null,["Firebase Hosting \nplat_web \nFirebase Hosting provides fast and secure hosting for your web app. \n\nFirebase Hosting is production-grade web content hosting for developers.\nWith a single command, you can quickly deploy web apps to a global CDN (content\ndelivery network).\n\nThough Firebase Hosting is optimized for static and\nsingle-page web apps, you can also [pair Firebase Hosting with\nCloud Functions or Cloud Run](/docs/hosting/serverless-overview) to\nbuild and host dynamic content and microservices on Firebase.\n\n[Get started](/docs/hosting/quickstart)\n\nKey capabilities\n\n|-------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Serve content over a secure connection | Zero-configuration SSL is built into Firebase Hosting, so content is always delivered securely. |\n| Deliver content fast | Each file that you upload is cached on SSDs at CDN edges around the world and served as gzip or Brotli. We auto-select the best compression method for your content. No matter where your users are, the content is delivered fast. |\n| Emulate and even share your changes before going live | View and test your changes on a locally hosted URL and interact with an emulated backend. Share your changes with teammates using temporary preview URLs. Hosting also provides a [GitHub integration](/docs/hosting/github-integration) for easy iterations of your previewed content. |\n| Deploy new versions with one command | Using the Firebase CLI, you can get your app up and running in seconds. Command line tools let you add deployment targets into your build process. And if you need to undo the deploy, Hosting provides one-click rollbacks. |\n\nHow does it work?\n\nWhether you are deploying a simple app landing page or a complex Progressive Web\nApp (PWA), Hosting gives you the infrastructure, features, and tooling\ntailored to deploying and managing websites and apps.\n\nUsing the [Firebase CLI](/docs/cli), you deploy files from local directories\non your computer to our Hosting servers. Beyond serving static content, you\ncan use Cloud Functions for Firebase or Cloud Run to\n[serve dynamic content and host microservices](/docs/hosting/serverless-overview)\non your sites. All content is\nserved over an SSL connection from the closest edge server on our global CDN.\n\nYou can also\n[view and test your changes before going live](/docs/hosting/test-preview-deploy).\nUsing the Firebase Local Emulator Suite,\nyou can emulate your app and backend resources at a locally hosted URL. You can\nalso share your changes at a temporary preview URL and set up a [GitHub\nintegration](/docs/hosting/github-integration) for easy iterations during\ndevelopment.\n\nFirebase Hosting has lightweight\n[hosting configuration options](/docs/hosting/full-config) for you\nto build sophisticated PWAs. You can\neasily rewrite URLs for client-side routing, set up custom headers, and even\nserve localized content.\n\nFor serving your content, Firebase offers several domain and subdomain options:\n\n- By default, every Firebase project has subdomains at no cost on the\n `web.app` and `firebaseapp.com` domains. These two sites serve the same\n deployed content and configuration.\n\n- You can [create multiple sites](/docs/hosting/multisites) if you have\n related sites and apps that serve different content but still share the same\n Firebase project resources (for example if you have a blog, admin panel, and\n public app).\n\n- You can [connect your own domain name](/docs/hosting/custom-domain) to a\n Firebase-hosted site.\n\nFirebase automatically provisions SSL certificates for all your domains so that\nall your content is served securely.\n\nImplementation path\n\n|---|-------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | Install the Firebase CLI | The [Firebase CLI](/docs/cli) makes it easy to set up a new Hosting project, run a local development server, and deploy content. |\n| | Set up a project directory | Add your static assets to a local project directory, then run firebase init to connect the directory to a Firebase project. In your local project directory, you can also set up Cloud Functions or Cloud Run for your [dynamic content and microservices](/docs/hosting/serverless-overview). |\n| | View, test, and share your changes before going live *(optional)* | Run firebase emulators:start to emulate Hosting and your backend project resources at a locally hosted URL. To view and share your changes at a temporary preview URL, run firebase hosting:channel:deploy to create and deploy to a preview channel. Set up the [GitHub integration](/docs/hosting/github-integration) for easy iterations of your previewed content. |\n| | Deploy your site | When things are looking good, run firebase deploy to upload the latest snapshot to our servers. If you need to undo the deploy, you can roll back with just one click in the Firebase console. |\n| | Link to a Firebase Web App *(optional)* | By linking your site to a [Firebase Web App](/docs/web/setup), you can use [Google Analytics](/docs/analytics/get-started?platform=web) to collect usage and behavior data for your app and use [Firebase Performance Monitoring](/docs/perf-mon/get-started-web) to gain insight into the performance characteristics of your app. |\n\nNext steps\n\n- [Get started](/docs/hosting/quickstart) with Firebase Hosting.\n\n- Continue to improve your site. Test locally, share changes at a temporary\n preview URL, then deploy to your live site. Follow this [step-by-step\n guide](/docs/hosting/test-preview-deploy).\n\n- [Build and host microservices](/docs/hosting/serverless-overview) on\n Firebase."]]