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.
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Firebase Hosting
plat_web
Firebase Hosting ให้บริการโฮสติ้งที่รวดเร็วและปลอดภัยสำหรับเว็บแอปของคุณ
Firebase Hosting เป็นบริการโฮสติ้งเนื้อหาเว็บระดับเวอร์ชันที่ใช้งานจริงสำหรับนักพัฒนาแอป
คุณสามารถทำให้เว็บแอปใช้งานได้อย่างรวดเร็วใน CDN (เครือข่ายการนำส่งเนื้อหา) ทั่วโลกได้ด้วยคำสั่งเดียว
แม้ว่า Firebase Hosting จะเพิ่มประสิทธิภาพสำหรับเว็บแอปแบบคงที่และแบบหน้าเดียว แต่คุณยังจับคู่ Firebase Hosting กับ Cloud Functions หรือ Cloud Run เพื่อสร้างและโฮสต์เนื้อหาแบบไดนามิกและไมโครเซอร์วิซใน Firebase ได้ด้วย
เริ่มต้นใช้งาน
ความสามารถหลัก
แสดงเนื้อหาผ่านการเชื่อมต่อที่ปลอดภัย |
ระบบจะแสดงเนื้อหาอย่างปลอดภัยเสมอเนื่องจากมีการสร้าง SSL ที่ไม่ต้องกำหนดค่าไว้ใน Firebase Hosting
|
ส่งเนื้อหาได้อย่างรวดเร็ว |
ไฟล์แต่ละไฟล์ที่คุณอัปโหลดจะแคชบน SSD ที่ CDN EDGE ทั่วโลก และแสดงเป็น gzip หรือ Brotli เราจะเลือกวิธีการบีบอัดที่ดีที่สุดสำหรับเนื้อหาของคุณโดยอัตโนมัติ เนื้อหาจะแสดงอย่างรวดเร็วไม่ว่าผู้ใช้จะอยู่ที่ใดก็ตาม
|
จำลองและแชร์การเปลี่ยนแปลงก่อนเผยแพร่ |
ดูและทดสอบการเปลี่ยนแปลงใน URL ที่โฮสต์ในเครื่อง และโต้ตอบกับแบ็กเอนด์ที่จำลอง
แชร์การเปลี่ยนแปลงกับเพื่อนร่วมทีมโดยใช้ URL ตัวอย่างชั่วคราว Hosting ยังมีการผสานรวม GitHub สำหรับการปรับปรุงเนื้อหาตัวอย่างของคุณซ้ำๆ ได้อย่างง่ายดาย
|
ติดตั้งใช้งานเวอร์ชันใหม่ด้วยคำสั่งเดียว |
คุณทำให้แอปทำงานได้ในไม่กี่วินาทีด้วย Firebase CLI เครื่องมือบรรทัดคำสั่งช่วยให้คุณเพิ่มเป้าหมายการทำให้ใช้งานได้ในกระบวนการบิลด์
และหากต้องการเลิกทำการติดตั้ง Hosting มีการย้อนกลับด้วยคลิกเดียว
|
วิธีการทำงาน
ไม่ว่าคุณจะทําให้หน้า Landing Page ของแอปทํางานได้หรือทําให้ Progressive Web App (PWA) ซับซ้อน Hosting ก็มีโครงสร้างพื้นฐาน ฟีเจอร์ และเครื่องมือที่ปรับให้เหมาะกับการใช้งานและการจัดการเว็บไซต์และแอป
เมื่อใช้ Firebase CLI คุณจะติดตั้งใช้งานไฟล์จากไดเรกทอรีในเครื่องคอมพิวเตอร์ไปยังเซิร์ฟเวอร์ Hosting ได้ นอกจากการแสดงเนื้อหาแบบคงที่แล้ว คุณยังใช้ Cloud Functions for Firebase หรือ Cloud Run เพื่อแสดงเนื้อหาแบบไดนามิกและโฮสต์ไมโครเซอร์วิสในเว็บไซต์ได้ด้วย เนื้อหาทั้งหมดจะแสดงผ่านการเชื่อมต่อ SSL จากเซิร์ฟเวอร์ Edge ที่ใกล้ที่สุดบน CDN ทั่วโลก
นอกจากนี้ คุณยังดูและทดสอบการเปลี่ยนแปลงก่อนเผยแพร่ได้ด้วย
เมื่อใช้ Firebase Local Emulator Suite คุณจำลองแอปและทรัพยากรแบ็กเอนด์ที่ URL ที่โฮสต์ในเครื่องได้ นอกจากนี้ คุณยังแชร์การเปลี่ยนแปลงที่ URL ตัวอย่างชั่วคราวและตั้งค่าการผสานรวม GitHub เพื่อให้ทำซ้ำได้ง่ายๆ ในระหว่างการพัฒนา
Firebase Hosting มีตัวเลือกการกำหนดค่าโฮสติ้งที่เบาช่วยให้คุณสร้าง PWA ที่ซับซ้อนได้ คุณสามารถเขียน URL ใหม่สําหรับการกำหนดเส้นทางฝั่งไคลเอ็นต์ ตั้งค่าส่วนหัวที่กําหนดเอง และแสดงเนื้อหาที่แปลแล้วได้ง่ายๆ
Firebase มีตัวเลือกโดเมนและโดเมนย่อยหลายรายการสำหรับแสดงเนื้อหา
โดยค่าเริ่มต้น โปรเจ็กต์ Firebase ทุกโปรเจ็กต์จะมีโดเมนย่อยแบบไม่มีค่าใช้จ่ายในโดเมน web.app
และ firebaseapp.com
เว็บไซต์ทั้ง 2 นี้แสดงเนื้อหาและการกำหนดค่าที่ติดตั้งใช้งานเดียวกัน
คุณสามารถสร้างเว็บไซต์หลายแห่งได้หากมีเว็บไซต์และแอปที่เกี่ยวข้องซึ่งแสดงเนื้อหาที่แตกต่างกันแต่ยังคงใช้ทรัพยากรโปรเจ็กต์ Firebase เดียวกัน (เช่น หากคุณมีบล็อก แผงการดูแลระบบ และแอปสาธารณะ)
คุณสามารถเชื่อมต่อชื่อโดเมนของคุณเองกับเว็บไซต์ที่โฮสต์โดย Firebase
Firebase จะจัดสรรใบรับรอง SSL ให้โดเมนทั้งหมดโดยอัตโนมัติเพื่อให้เนื้อหาทั้งหมดแสดงอย่างปลอดภัย
เส้นทางการใช้งาน
|
ติดตั้ง Firebase CLI |
Firebase CLI ช่วยให้คุณตั้งค่าโปรเจ็กต์ Hosting ใหม่ เรียกใช้เซิร์ฟเวอร์การพัฒนาซอฟต์แวร์ภายใน และทำให้เนื้อหาใช้งานได้อย่างง่ายดาย
|
|
ตั้งค่าไดเรกทอรีโปรเจ็กต์ |
เพิ่มชิ้นงานแบบคงที่ลงในไดเรกทอรีโปรเจ็กต์ในเครื่อง แล้วเรียกใช้ firebase init เพื่อเชื่อมต่อไดเรกทอรีกับโปรเจ็กต์ Firebase
ในไดเรกทอรีโปรเจ็กต์ในเครื่อง คุณยังตั้งค่า Cloud Functions หรือ Cloud Run สำหรับเนื้อหาแบบไดนามิกและไมโครเซอร์วิสได้ด้วย
|
|
ดู ทดสอบ และแชร์การเปลี่ยนแปลงก่อนเผยแพร่ (ไม่บังคับ) |
เรียกใช้ firebase emulators:start เพื่อจําลอง Hosting และทรัพยากรโปรเจ็กต์แบ็กเอนด์ที่ URL ที่โฮสต์ในเครื่อง
หากต้องการดูและแชร์การเปลี่ยนแปลงใน URL ตัวอย่างชั่วคราว ให้เรียกใช้ firebase hosting:channel:deploy เพื่อสร้างและทำให้ใช้งานได้ในช่องทางตัวอย่าง ตั้งค่าการผสานรวม GitHub เพื่อให้คุณทำซ้ำเนื้อหาที่แสดงตัวอย่างได้อย่างง่ายดาย
|
|
ติดตั้งใช้งานเว็บไซต์ |
เมื่อทุกอย่างเรียบร้อยดีแล้ว ให้เรียกใช้ firebase deploy เพื่ออัปโหลดภาพรวมล่าสุดไปยังเซิร์ฟเวอร์ของเรา หากต้องการเลิกใช้งานการทําให้ใช้งานได้ คุณสามารถย้อนกลับได้ด้วยการคลิกเพียงครั้งเดียวในคอนโซล Firebase
|
|
ลิงก์กับเว็บแอป Firebase (ไม่บังคับ) |
การลิงก์เว็บไซต์กับ เว็บแอป Firebase จะช่วยให้คุณใช้ Google Analytics เพื่อรวบรวมข้อมูลการใช้งานและพฤติกรรมสําหรับแอป รวมถึงใช้ Firebase Performance Monitoring เพื่อรับข้อมูลเชิงลึกเกี่ยวกับลักษณะประสิทธิภาพของแอปได้
|
ขั้นตอนถัดไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-08 UTC
[null,null,["อัปเดตล่าสุด 2025-08-08 UTC"],[],[],null,["# Firebase Hosting\n================\n\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|-------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\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-----------------\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|---|-------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\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\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."]]