Deploy your Astro Site to Google’s Firebase Hosting
Firebase Hosting is a service provided by Google’s Firebase app development platform, which can be used to deploy an Astro site.
See our separate guide for adding Firebase backend services such as databases, authentication, and storage.
Project Configuration
Заголовок раздела «Project Configuration»Your Astro project can be deployed to Firebase as a static site, or as a server-side rendered site (SSR).
Static Site
Заголовок раздела «Static Site»Your Astro project is a static site by default. You don’t need any extra configuration to deploy a static Astro site to Firebase.
Adapter for SSR
Заголовок раздела «Adapter for SSR»To enable SSR in your Astro project and deploy on Firebase add the Node.js adapter.
Deploying an SSR Astro site to Firebase requires the Blaze plan or higher.
How to deploy
Заголовок раздела «How to deploy»-
Install the Firebase CLI. This is a command-line tool that allows you to interact with Firebase from the terminal.
Окно терминала npm install firebase-toolsОкно терминала pnpm add firebase-toolsОкно терминала yarn add firebase-tools -
Authenticate the Firebase CLI with your Google account. This will open a browser window where you can log in to your Google account.
Окно терминала npx firebase loginОкно терминала pnpm exec firebase loginОкно терминала yarn firebase login -
Enable experimental web frameworks support. This is an experimental feature that allows the Firebase CLI to detect and configure your deployment settings for Astro.
Окно терминала npx firebase experiments:enable webframeworksОкно терминала pnpm exec firebase experiments:enable webframeworksОкно терминала yarn firebase experiments:enable webframeworks -
Initialize Firebase Hosting in your project. This will create a
firebase.jsonand.firebasercfile in your project root.Окно терминала npx firebase init hostingОкно терминала pnpm exec firebase init hostingОкно терминала yarn firebase init hosting -
Deploy your site to Firebase Hosting. This will build your Astro site and deploy it to Firebase.
Окно терминала npx firebase deploy --only hostingОкно терминала pnpm exec firebase deploy --only hostingОкно терминала yarn firebase deploy --only hosting