firebase-cli
Original:🇺🇸 English
Translated
3 scripts
Install, configure, and operate the Firebase CLI (firebase-tools) for all Firebase services. Use when you need to deploy to Firebase Hosting, Cloud Functions, Firestore, Realtime Database, Cloud Storage, Extensions, App Hosting, or run the Firebase Emulator Suite. Triggers on: firebase deploy, firebase init, firebase emulators, firebase hosting, firebase functions, firebase firestore, firebase database, firebase auth import, firebase remote config, firebase app distribution, firebase extensions, firebase apphosting, firebase cli, firebase-tools, deploy firebase, firebase preview channel, firebase login, firebase serve.
2installs
Added on
NPX Install
npx skill4agent add supercent-io/skills-template firebase-cliTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →firebase-cli — Firebase Command Line Interface
Keyword:·firebase·firebase deploy·firebase initfirebase emulatorsThe Firebase CLI () manages your Firebase project from the terminal: deploy, emulate, import/export data, manage users, configure services, and automate CI/CD.firebase-tools
When to use this skill
- Deploy Firebase Hosting, Cloud Functions, Firestore rules/indexes, Realtime Database rules, Cloud Storage rules, Remote Config, or Extensions
- Set up a new Firebase project with
firebase init - Run the Firebase Emulator Suite locally for development and testing
- Manage preview/staging channels for Hosting
- Import or export Firebase Authentication users in bulk
- Distribute app builds to testers via App Distribution
- Manage Firebase Extensions (install, configure, update, uninstall)
- Deploy Next.js / Angular apps via Firebase App Hosting
- Use Firebase CLI in CI/CD pipelines with service account credentials
Instructions
- Install the Firebase CLI:
npm install -g firebase-tools - Authenticate: (browser OAuth) or
firebase loginfor CIGOOGLE_APPLICATION_CREDENTIALS - Initialize project: (creates
firebase initandfirebase.json).firebaserc - Deploy: or
firebase deployfirebase deploy --only hosting,functions - Run emulators:
firebase emulators:start - For detailed command reference, see references/commands.md
- For installation and setup scripts, see scripts/install.sh
CI/CD: Useinstead of the deprecatedGOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json firebase deploy/--tokenmethod.FIREBASE_TOKEN
Examples
Deploy everything
bash
firebase deployDeploy only Hosting and Functions
bash
firebase deploy --only hosting,functionsRun all emulators with data persistence
bash
firebase emulators:start --import ./emulator-data --export-on-exitCreate a preview channel and deploy
bash
firebase hosting:channel:create staging --expires 7d
firebase hosting:channel:deploy stagingImport users from JSON
bash
firebase auth:import users.json --hash-algo=BCRYPTDistribute Android build to testers
bash
firebase appdistribution:distribute app-release.apk \
--app "1:1234567890:android:abcd1234" \
--release-notes "Sprint 42 build" \
--groups "qa-team"Quick Start
bash
# Install
npm install -g firebase-tools
# Authenticate
firebase login
# Initialize project (interactive)
firebase init
# Deploy
firebase deploy
# Run emulators
firebase emulators:startInstallation
npm (recommended — all platforms)
bash
npm install -g firebase-tools
firebase --versionStandalone binary (macOS/Linux — no Node.js required)
bash
curl -sL firebase.tools | bashCI/CD — service account authentication (recommended)
bash
# Set environment variable pointing to service account JSON key
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
firebase deploy --non-interactiveVia skill script
bash
bash scripts/install.shCore Usage
Authentication
bash
firebase login # OAuth browser login
firebase login --no-localhost # Copy-paste code flow
firebase login:ci # Generate CI token (deprecated — use service account)
firebase login:list # List all authorized accounts
firebase login:use user@example.com # Set default account
firebase logout # Sign outProject Management
bash
firebase init # Set up Firebase features in current directory
firebase use <project_id> # Set active project
firebase use --add # Add a project alias
firebase projects:list # List all Firebase projects
firebase open hosting:site # Open Firebase console in browserDeployment
bash
# Deploy everything
firebase deploy
# Deploy specific targets
firebase deploy --only hosting
firebase deploy --only functions
firebase deploy --only firestore
firebase deploy --only hosting,functions
# Deploy sub-targets
firebase deploy --only functions:myFunction
firebase deploy --only hosting:my-site
firebase deploy --only firestore:rules
firebase deploy --only firestore:indexes
# Exclude targets
firebase deploy --except functions
# With message
firebase deploy --message "v2.3.1 release"Firebase Emulator Suite
bash
# Start all configured emulators
firebase emulators:start
# Start specific emulators
firebase emulators:start --only auth,firestore,functions
# With data import/export
firebase emulators:start --import ./emulator-data --export-on-exit
# Run tests against emulators then shut down
firebase emulators:exec "npm test" --only firestore,auth
# Enable Functions debugger (Node.js inspector on port 9229)
firebase emulators:start --inspect-functionsLocal Development Server
bash
firebase serve # Hosting + HTTPS Functions
firebase serve --only hosting
firebase serve --port 5000Hosting Commands
bash
# Preview channels
firebase hosting:channel:create staging --expires 7d
firebase hosting:channel:deploy staging
firebase hosting:channel:list
firebase hosting:channel:open staging
firebase hosting:channel:delete staging --force
firebase hosting:clone my-app:live my-app-staging:staging
# Multi-site management
firebase hosting:sites:list
firebase hosting:sites:create new-site-id
firebase hosting:disable --site my-old-siteCloud Functions Commands
bash
firebase functions:list # List deployed functions
firebase functions:log # View logs
firebase functions:log --only myFunction # Filter by function name
firebase functions:delete myFunction # Delete a function
firebase functions:shell # Local interactive shell
# Secrets (2nd gen — replaces functions:config)
firebase functions:secrets:set MY_SECRET
firebase functions:secrets:get MY_SECRET
firebase functions:secrets:prune
# Config (1st gen only)
firebase functions:config:set api.key="VALUE"
firebase functions:config:getFirestore Commands
bash
firebase firestore:delete /collection/doc --recursive
firebase firestore:indexes
firebase firestore:rules:getRealtime Database Commands
bash
firebase database:get /path --pretty
firebase database:set /path data.json
firebase database:push /messages --data '{"text":"Hello"}'
firebase database:update /users/uid --data '{"name":"New Name"}'
firebase database:remove /path --confirm
firebase database:profile --duration 30Auth Import / Export
bash
# Export all users
firebase auth:export users.json
# Import users (BCRYPT hashes)
firebase auth:import users.json --hash-algo=BCRYPT
# Import users (SCRYPT hashes — Firebase default)
firebase auth:import users.json \
--hash-algo=SCRYPT \
--hash-key=<base64-key> \
--salt-separator=<base64-separator> \
--rounds=8 \
--mem-cost=8Remote Config
bash
firebase remoteconfig:get
firebase remoteconfig:get --output config.json
firebase remoteconfig:versions:list --limit 20
firebase remoteconfig:rollback --version-number 5App Distribution
bash
# Distribute Android APK
firebase appdistribution:distribute app.apk \
--app APP_ID \
--release-notes "Bug fixes and improvements" \
--testers "qa@example.com" \
--groups "qa-team,beta-users"
# Manage testers
firebase appdistribution:testers:add alice@example.com --group-alias qa-team
firebase appdistribution:testers:remove alice@example.com
firebase appdistribution:groups:listExtensions
bash
firebase ext:list
firebase ext:info firebase/delete-user-data
firebase ext:install firebase/delete-user-data
firebase ext:configure delete-user-data
firebase ext:update delete-user-data
firebase ext:uninstall delete-user-data
firebase ext:exportApp Hosting (Next.js / Angular)
bash
firebase init apphosting
firebase apphosting:backends:create --location us-central1
firebase apphosting:backends:list
firebase deploy --only apphosting
firebase apphosting:rollouts:create BACKEND_ID --git-branch mainDeploy Targets (multi-site / multi-instance)
bash
# Apply target name to a resource
firebase target:apply hosting prod-site my-app-prod
firebase target:apply storage prod-bucket my-app-bucket
firebase target:apply database default my-app-db
# Use target in deploy
firebase deploy --only hosting:prod-site
# Clear targets
firebase target:clear hosting prod-siteBest practices
- Use service accounts for CI/CD: Set instead of
GOOGLE_APPLICATION_CREDENTIALS(deprecated).--token - Use in deploy: Never deploy everything blindly in production — always scope with
--only.--only - Emulators for development: Always run locally before deploying; use
emulators:start/--importfor persistence.--export-on-exit - Preview channels before production: Use for staging reviews before
hosting:channel:deploy.firebase deploy --only hosting - Secrets over functions:config: For Cloud Functions 2nd gen, use (Secret Manager) instead of deprecated
functions:secrets:set.functions:config:set - in scripts: Always add
--non-interactivein automated scripts to avoid hanging on prompts.--non-interactive - in VCS: Commit
.firebaserc(project aliases) but add secrets and service account keys to.firebaserc..gitignore - for troubleshooting: Run any failing command with
--debugfor verbose output.--debug
Troubleshooting
| Issue | Solution |
|---|---|
| Run |
| Authentication error in CI | Set |
| Migrate from token-based auth to service accounts |
| Deploy fails with permission error | Verify service account has required IAM roles (Firebase Admin, Cloud Functions Admin, etc.) |
| Emulators not starting | Check ports 4000/5000/5001/8080/9000/9099/9199 are available; run |
| Functions deploy timeout | Use |
| Hosting deploy not reflecting changes | Check |
| Check extension ID format: |
| Database permission denied | Verify database rules and that CLI auth account has access |
References
- Firebase CLI Reference — official full command reference
- Full Command Reference — complete options and flags for all commands
- Install Scripts — (setup) ·
install.sh(deployment helper) ·deploy.sh(emulator management)emulators.sh - firebase-tools GitHub — source code and changelog
- Firebase CLI Release Notes — version history
- Auth Import/Export Reference — hash algorithm details
- Hosting Preview Channels — staging workflow
- Emulator Suite Configuration — emulator setup