If you are building server-rendered Angular or Next.js apps, check out next-generation Firebase App Hosting, a full-stack solution for modern web frameworks.
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Firebase Hosting cung cấp cho bạn một cách nhanh chóng, an toàn và đáng tin cậy để lưu trữ các tài sản tĩnh của ứng dụng (HTML, CSS, JavaScript, tệp đa phương tiện, v.v.) cũng như để phân phát nội dung động và lưu trữ các vi dịch vụ.
Dịch vụ lưu trữ cấp sản xuất của chúng tôi được hỗ trợ bởi một mạng phân phối nội dung (CDN) toàn cầu. Theo mặc định, Hosting phân phát nội dung của bạn qua SSL và có thể được dùng với miền tuỳ chỉnh của riêng bạn hoặc trên các miền phụ của dự án mà không mất phí trên web.app và firebaseapp.com.
Để kết nối các tệp dự án cục bộ với dự án Firebase, hãy chạy lệnh sau từ gốc của thư mục dự án cục bộ:
firebase init hosting
Trong quá trình chạy dự án, từ lời nhắc của CLI Firebase:
Chọn một dự án Firebase để kết nối với thư mục dự án cục bộ của bạn.
Dự án Firebase đã chọn là dự án Firebase "mặc định" cho thư mục dự án cục bộ của bạn. Để kết nối các dự án Firebase khác với thư mục dự án cục bộ, hãy thiết lập bí danh dự án.
Chỉ định một thư mục để dùng làm thư mục gốc công khai của bạn.
Thư mục này chứa tất cả các tệp tĩnh được phân phát công khai, bao gồm cả tệp index.html và mọi tài sản khác mà bạn muốn triển khai đến Firebase Hosting.
Thư mục gốc công khai mặc định có tên là public.
Bạn có thể chỉ định thư mục gốc công khai ngay bây giờ hoặc chỉ định sau trong tệp cấu hình firebase.json.
Nếu bạn chọn thư mục mặc định và chưa có thư mục nào có tên public, thì Firebase sẽ tạo thư mục đó cho bạn.
Nếu bạn chưa có tệp index.html hoặc tệp 404.html hợp lệ trong thư mục gốc công khai, thì Firebase sẽ tạo các tệp này cho bạn.
Chọn một cấu hình cho trang web của bạn.
Nếu bạn chọn tạo một ứng dụng một trang, thì Firebase sẽ tự động thêm cấu hình viết lại cho bạn.
Khi kết thúc quá trình khởi chạy, Firebase sẽ tự động tạo và thêm 2 tệp vào gốc thư mục ứng dụng cục bộ của bạn:
Tệp cấu hình firebase.json liệt kê cấu hình dự án của bạn.
Tìm hiểu thêm về tệp này trên trang định cấu hình hành vi lưu trữ.
Giờ đây, trang web của bạn đã sẵn sàng để chia sẻ với mọi người!
Tiếp tục cải thiện trang web của bạn. Kiểm thử cục bộ, chia sẻ các thay đổi tại một URL xem trước tạm thời, sau đó triển khai cho trang web đang hoạt động của bạn. Làm theo hướng dẫn từng bước này.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[],[],null,["\u003cbr /\u003e\n\nFirebase Hosting gives you a fast, secure, and reliable way to host your\napp's static assets (HTML, CSS, JavaScript, media files, etc.) as well as to\n[serve dynamic content and host microservices](/docs/hosting/serverless-overview).\n\nOur production-grade hosting is backed by a global content delivery network\n(CDN). Hosting serves your content over SSL, by default, and can be used\nwith your own [custom domain](/docs/hosting/custom-domain) or on your project's\nsubdomains at no cost on `web.app` and `firebaseapp.com`.\n\nBefore you begin\n\nBefore you can set up Firebase Hosting, you need to\n[create a Firebase project](/docs/web/setup).\n\n**Step 1** : Install the Firebase CLI\n\nVisit the Firebase CLI documentation to learn how to\n[install the CLI](/docs/cli#install_the_firebase_cli) or\n[update to its latest version](/docs/cli#update-cli).\n\n**Step 2**: Initialize your project\n\nTo connect your local project files to your Firebase project, run the following\ncommand from the root of your local project directory: \n\n```\nfirebase init hosting\n```\n\nDuring project initialization, from the Firebase CLI prompts:\n\n1. **Select a Firebase project to connect to your local project directory.**\n\n The selected Firebase project is your \"default\" Firebase project for your\n local project directory. To connect additional Firebase projects to your\n local project directory, set up [project aliases](/docs/cli#project_aliases).\n2. **Specify a directory to use as your public root directory.**\n\n This directory contains all your publicly served static files, including your\n `index.html` file and any other assets that you want to deploy to\n Firebase Hosting.\n - The default for the public root directory is called `public`.\n\n - You can specify your public root directory now or you can\n [specify it later](/docs/hosting/full-config#public) in your\n `firebase.json` configuration file.\n\n - If you select the default and don't already have a directory called\n `public`, Firebase creates it for you.\n\n - If you don't already have a valid `index.html` file or `404.html` file in\n your public root directory, Firebase creates them for you.\n\n3. **Choose a configuration for your site.**\n\n If you select to make a one-page app, then Firebase automatically adds\n [rewrite configurations](/docs/hosting/full-config#rewrites) for you.\n\nAt the end of initialization, Firebase automatically creates and adds two files\nto the root of your local app directory:\n\n- A `firebase.json` configuration file that lists your project configuration.\n Learn more about this file on the\n [configure hosting behavior](/docs/hosting/full-config) page.\n\n- A `.firebaserc` file that stores your\n [project aliases](/docs/cli#project_aliases).\n\n**Step 3**: Deploy to your site\n\nTo deploy to your site, run the following command from the root of your local\nproject directory: \n\n```\nfirebase deploy --only hosting\n```\n| **Note:** By running this command with the `--only hosting` flag, you're only deploying your Hosting content and config. If you *also* want to [deploy other project resources or configurations](/docs/cli#partial_deploys) (like functions or database rules), run this command with a comma-separated list in the flag (for example, `--only hosting,functions`).\n\nThis command deploys your Hosting content and config to the following\nFirebase-provisioned subdomains:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.web.app`\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.firebaseapp.com`\n\nLearn more about\n[deploys and even locally testing your site](/docs/hosting/test-preview-deploy).\n\nNext steps\n\nNow your site is ready to share with the world!\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\n [step-by-step guide](/docs/hosting/test-preview-deploy).\n\n- Learn about further hosting capabilities:\n\n - [Configure hosting behavior](/docs/hosting/full-config)\n - [Connect a custom domain](/docs/hosting/custom-domain)\n - [Serve dynamic content and host microservices](/docs/hosting/serverless-overview)\n- Take a look at the full documentation for the [Firebase CLI](/docs/cli).\n\n- Prepare to launch your app:\n\n\n - Set up [budget\n alerts](/docs/projects/billing/avoid-surprise-bills#set-up-budget-alert-emails) for your project in the Google Cloud console.\n - Monitor the [*Usage and billing*\n dashboard](//console.firebase.google.com/project/_/usage) in the Firebase console to get an overall picture of your project's usage across multiple Firebase services. You can also visit the [Hosting *Usage*\n dashboard](//console.firebase.google.com/project/_/hosting/usage) for more detailed usage information.\n - Review the [Firebase launch checklist](/support/guides/launch-checklist)."]]