透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Firebase Hosting
plat_web
主要功能
透過安全連線提供內容 |
Firebase Hosting 內建零設定 SSL,因此可以持續安全遞送內容。 |
快速傳遞內容 |
您上傳的每個檔案都會以快取形式儲存在全球 CDN 邊緣伺服器的固態硬碟 (SSD),並以 gzip 或 Brotli 格式提供服務。我們會自動為您的內容選用最佳壓縮方法。無論使用者位在哪裡,都能快速傳遞內容。 |
在正式發布前模擬及分享變更 |
在本機代管的網址上查看及測試變更,並與模擬的後端互動。
使用臨時預覽網址與同事分享變更內容。Hosting 也提供 GitHub 整合功能,方便您對預覽內容進行疊代。
|
單一指令即可部署新版本 |
使用 Firebase CLI 時,在幾秒鐘內即可啟動並執行您的應用程式。指令列工具可讓您在建構程序中新增部署目標。
如果您需要復原部署作業,Hosting 提供一鍵式復原作業。
|
運作原理
無論您要部署簡單的應用程式到達網頁,還是複雜的漸進式網頁應用程式 (PWA),Hosting 都能提供專為部署及管理網站和應用程式而設計的基礎架構、功能和工具。
您可以使用 Firebase CLI,將電腦本機目錄中的檔案部署至 Hosting 伺服器。除了提供靜態內容,您也可以使用 Cloud Functions for Firebase 或 Cloud Run,在網站上提供動態內容和託管微服務。所有內容都會透過 SSL 連線,從全球 CDN 上最近的邊緣伺服器提供。
您也可以在正式發布前查看及測試變更內容。使用 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 網頁應用程式(選用) |
將網站連結至 Firebase Web 應用程式後,您就能使用 Google Analytics 收集應用程式的使用和行為資料,並使用 Firebase Performance Monitoring 深入瞭解應用程式的效能特性。 |
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-08 (世界標準時間)。
[null,null,["上次更新時間: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."]]