0
0
Firebasecloud~5 mins

Firebase CLI setup - Commands & Configuration

Choose your learning style9 modes available
Introduction
Setting up the Firebase CLI lets you manage your Firebase projects from your computer. It helps you deploy apps, manage databases, and configure services easily without using the web console.
When you want to deploy a web or mobile app to Firebase hosting from your computer.
When you need to initialize a new Firebase project with default settings.
When you want to manage Firebase services like Firestore or Functions using command line.
When you want to test Firebase features locally before publishing.
When you want to update your Firebase project configuration quickly without using the web interface.
Commands
This command installs the Firebase CLI globally on your computer so you can use it anywhere.
Terminal
npm install -g firebase-tools
Expected OutputExpected
+ firebase-tools@latest added 50 packages from 30 contributors in 10s
This command logs you into your Firebase account so the CLI can access your projects.
Terminal
firebase login
Expected OutputExpected
✔ Success! Logged in as your-email@example.com
This command starts the setup for a new Firebase project in your current folder, letting you choose features to use.
Terminal
firebase init
Expected OutputExpected
You're about to initialize a Firebase project in this directory: ? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choices. ? Select features: Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys === Hosting Setup ? What do you want to use as your public directory? public ? Configure as a single-page app (rewrite all urls to /index.html)? Yes ? Set up automatic builds and deploys with GitHub? No Firebase initialization complete!
This command uploads your app and configuration to Firebase so it becomes live on the internet.
Terminal
firebase deploy
Expected OutputExpected
=== Deploying to 'your-project-id'... i deploying hosting ✔ hosting: example-project-1234.web.app ✔ hosting: example-project-1234.firebaseapp.com ✔ Deploy complete! Project Console: https://console.firebase.google.com/project/your-project-id/overview
Key Concept

If you remember nothing else from this pattern, remember: the Firebase CLI lets you control your Firebase projects easily from your computer with simple commands.

Common Mistakes
Trying to run Firebase CLI commands without installing firebase-tools first.
The commands won't work because the CLI program is not available on your computer.
Always run 'npm install -g firebase-tools' first to install the CLI.
Running 'firebase deploy' before logging in with 'firebase login'.
The CLI cannot access your Firebase projects without login, so deployment fails.
Run 'firebase login' and complete authentication before deploying.
Not selecting the correct features during 'firebase init'.
Your project may miss important setup files or configurations needed for your app.
Carefully choose the features you need during initialization, like Hosting or Firestore.
Summary
Install Firebase CLI globally using npm to get access to Firebase commands.
Log in to your Firebase account with 'firebase login' to connect the CLI to your projects.
Initialize your project folder with 'firebase init' to set up Firebase features.
Deploy your app and settings to Firebase with 'firebase deploy' to make it live.