Firebase CLI
Official CLI for Firebase. Manage hosting, functions, Firestore, auth, and storage.
- Official repo: https://github.com/firebase/firebase-tools
- Docs: https://firebase.google.com/docs/cli
Authentication
firebase login # Browser-based login
firebase login --no-localhost # For remote/headless environments
firebase projects:list # List available projects
firebase use PROJECT_ID # Select active project
Common Commands
Project Setup
firebase init # Interactive project setup
firebase init hosting functions firestore # Init specific features
firebase projects:list
firebase use --add # Add project alias
Hosting
firebase deploy --only hosting # Deploy hosting
firebase hosting:channel:deploy preview # Preview channel
firebase hosting:channel:list
firebase hosting:disable # Take site offline
Cloud Functions
firebase deploy --only functions # Deploy all functions
firebase deploy --only functions:myFunction # Deploy specific function
firebase functions:log # View function logs
firebase functions:shell # Interactive function testing
firebase emulators:start --only functions # Local emulator
Firestore
firebase firestore:indexes # List indexes
firebase firestore:delete --all-collections # Delete all data (careful!)
firebase emulators:start --only firestore # Local emulator
Emulators
firebase emulators:start # Start all emulators
firebase emulators:start --only auth,firestore # Specific emulators
firebase emulators:export ./backup # Export emulator data
firebase emulators:start --import=./backup # Import on start
Extensions
firebase ext:install firebase/firestore-send-email
firebase ext:list
Agent Best Practices
- Use
firebase emulators:startfor local development and testing - Deploy specific features with
--onlyto avoid unintended changes - Use
firebase deploy --only hostingfor frontend-only deploys - Check
firebase useto confirm active project before deploying - Use preview channels for testing:
firebase hosting:channel:deploy staging - Export/import emulator data to preserve test state
Example Workflows
Deploy full project
firebase deploy
Start local dev environment
firebase emulators:start --import=./emulator-data --export-on-exit=./emulator-data