Skip to content

Firebase

How to Deploy Astro JS to Firebase

Firebase Hosting is Google’s static hosting platform — free, fast, and backed by Google’s global CDN.

This guide walks you through deploying your Blacks project to Firebase Hosting.


Firebase Sign Up

Firebase astro js themes template

First, create a Firebase account at firebase.google.com. It’s free.


Install Firebase CLI

Install the Firebase CLI globally on your machine:

Terminal window
npm install -g firebase-tools

Log In to Firebase

Authenticate the CLI with your Firebase account:

Terminal window
firebase login

This opens your browser. Sign in and authorize the CLI.


Initialize Firebase

Create a new folder for your Firebase project, then initialize it:

Terminal window
firebase init

Follow the prompts to set up Firebase Hosting.


Move Your Astro Project

Move your Astro JS project into the Firebase project folder.

Then go back to your Firebase dashboard and create a new project — name it whatever you want.


Build Production

Back in your Astro project folder, run the production build:

Terminal window
npm run build

This generates the dist folder containing your static site.


Deploy to Firebase

After building, access your dist folder from the terminal, then run:

Terminal window
firebase add && firebase deploy

Firebase uploads your files and publishes them to the global CDN.

Your site is now live at:

https://your-project.web.app

For detailed Firebase CLI documentation, visit:

👉 Firebase CLI Documentation →


Build Settings Summary

SettingValue
Build commandnpm run build
Output directorydist
Public directorydist (in Firebase config)

Troubleshooting

ProblemSolution
firebase: command not foundReinstall with npm install -g firebase-tools
firebase login failsAllow popups in your browser, or use firebase login --no-localhost
Deploy failsRun npm run build first before firebase deploy
404 errorsMake sure the public directory is set to dist in firebase.json
Changes not showingHard refresh in your browser (Ctrl + Shift + R)

Next Step

Explore other hosting options:

👉 Netlify — alternative static host with drag-and-drop deploy