Skip to main content

Deploy with Firebase CLI ⚡

Get your website live on Firebase Hosting using the traditional command-line interface. This guide provides direct control over your deployment process.

Prefer AI assistance?

Want to deploy using natural language commands? Check out our Gemini AI Quick Start Guide for a conversational deployment experience!

Prerequisites

You'll need:

  • Node.js version 14 or higher (only required for Firebase CLI installation)
  • A Google account for Firebase
  • A folder with HTML files to deploy (or we'll create one!)

Step 1: Install Firebase CLI (15 seconds)

Open your terminal and run:

npm install -g firebase-tools
tip

Already have Firebase CLI? Update it with the same command to get the latest features!

Step 2: Create Your Project (15 seconds)

Let's create a simple website to deploy. Run these commands:

# Create a new directory
mkdir my-awesome-site
cd my-awesome-site

# Create a simple HTML file
echo '<!DOCTYPE html>
<html>
<head>
<title>My Awesome Site</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.container { text-align: center; }
h1 { font-size: 3em; margin-bottom: 0.5em; }
p { font-size: 1.5em; }
</style>
</head>
<body>
<div class="container">
<h1>🚀 Hello, Firebase Hosting!</h1>
<p>This site was deployed in 60 seconds!</p>
</div>
</body>
</html>' > index.html

Step 3: Initialize Firebase (15 seconds)

Initialize Firebase Hosting in your project:

firebase init hosting

When prompted:

  1. Create a new project or select an existing one
  2. Public directory: Press Enter (uses current directory)
  3. Single-page app: Type N and press Enter
  4. Set up automatic builds: Type N and press Enter

Step 4: Deploy! (15 seconds)

Now for the magic moment:

firebase deploy

🎉 That's it! Your site is now live at:

  • https://YOUR-PROJECT-ID.web.app
  • https://YOUR-PROJECT-ID.firebaseapp.com

What Just Happened?

In just 60 seconds, you:

  1. ✅ Installed the Firebase CLI
  2. ✅ Created a simple website
  3. ✅ Initialized Firebase Hosting
  4. ✅ Deployed to a global CDN

Your site is now:

  • 🌍 Available worldwide on 200+ edge servers
  • 🔒 Secured with automatic SSL
  • ⚡ Optimized with automatic compression
  • 📊 Ready for millions of visitors

Next Steps

Make Changes and Redeploy

Edit your index.html and redeploy:

# Make your changes
echo '<p>Updated at: '"$(date)"'</p>' >> index.html

# Deploy again
firebase deploy

Preview Before Deploying

Want to test changes before going live?

# Test locally
firebase emulators:start

# Create a preview channel
firebase hosting:channel:deploy preview

Connect a Custom Domain

Make it yours with a custom domain:

firebase hosting:sites:create my-custom-site
firebase target:apply hosting my-custom-site my-custom-site
firebase deploy --only hosting:my-custom-site

Common Commands Cheat Sheet

CommandDescription
firebase deployDeploy to production
firebase serveTest locally
firebase hosting:channel:deploy previewCreate preview URL
firebase hosting:clone SOURCE:preview TARGET:livePromote preview to production
firebase hosting:disableTake site offline

Troubleshooting

"Command not found: firebase"

Make sure you installed Firebase CLI globally with -g flag

"Error: Failed to get Firebase project"

Run firebase login to authenticate

"Error: Specified public directory does not exist"

Create the directory or update the path in firebase.json

What's Next?

🔧 Configure Your Site

Learn about firebase.json configuration options

Configuration Guide →

🚀 Explore Features

Preview channels, rollbacks, and more

Features Overview →

🌐 Custom Domains

Connect your own domain name

Domain Setup →

🤖 Try Gemini AI

Deploy using natural language commands

Gemini Guide →

Congratulations! You've joined thousands of developers who deploy with Firebase Hosting. Your site is fast, secure, and ready to scale. 🎊