Skip to content

Latest commit

Β 

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”₯ firestack-cli

One command. All platforms & frameworks. Zero Firebase setup headache.

npm version npm downloads License: MIT Node β‰₯18

Automatically configure Firebase for Next.js, Expo, React (Vite / CRA), Bare React Native, Remix, Astro, and SvelteKit β€” across Android, iOS, and Web.

npx firestack-cli setup

πŸ“– Table of Contents


✨ Why firestack-cli?

Setting up Firebase across different frameworks and platforms is tedious:

  • Next.js: Register web app β†’ generate NEXT_PUBLIC_* in .env.local β†’ initialize singleton src/lib/firebase.ts β†’ setup Auth & Firestore.
  • Expo: Register iOS & Android apps β†’ download google-services.json & GoogleService-Info.plist β†’ configure app.json plugins & EXPO_PUBLIC_* env vars.
  • React (Vite / CRA): Register web app β†’ configure VITE_* / REACT_APP_* in .env β†’ initialize client SDK.
  • Bare React Native: Patch root and app build.gradle β†’ drop plist in Xcode folder β†’ setup @react-native-firebase/app.

firestack-cli automates all of that with intelligent framework detection and direct Firebase API integration.

Your Project (Next.js / Expo / Vite / React Native / Remix)
                           β”‚
                           β–Ό
                     firestack-cli
                           β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β–Ό                 β–Ό                 β–Ό
   Web Frameworks         Expo          Bare React Native
 (Next.js/Vite/CRA)   (iOS/Android/Web)   (Android/iOS Native)
         β”‚                 β”‚                 β”‚
   .env / lib/firebase   app.json + plists   Gradle + plists
         β”‚                 β”‚                 β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β–Ό
                   Firebase Ready πŸ”₯

🌟 Framework Support

Framework Detection Trigger Config File Location Env Vars Format SDK Configured
Next.js (App & Pages) next src/lib/firebase.ts / lib/firebase.ts NEXT_PUBLIC_FIREBASE_* in .env.local firebase (JS SDK)
Expo (Managed & Bare) expo, app.json app.json + google-services.json + GoogleService-Info.plist EXPO_PUBLIC_FIREBASE_* in .env @react-native-firebase or firebase
React (Vite) vite + react src/lib/firebase.ts / src/firebase.ts VITE_FIREBASE_* in .env firebase (JS SDK)
Create React App react-scripts src/firebase.ts REACT_APP_FIREBASE_* in .env firebase (JS SDK)
Bare React Native react-native android/app/google-services.json & ios/.../GoogleService-Info.plist Native Gradle / Plist @react-native-firebase/app
Remix / Astro / Svelte package matches src/lib/firebase.ts / app/lib/firebase.ts Framework-specific env prefix firebase (JS SDK)

πŸ“¦ Install

Use without installing (recommended)

npx firestack-cli setup
# or
bunx firestack-cli setup

Install globally

# npm
npm install -g firestack-cli

# bun
bun add -g firestack-cli

# pnpm
pnpm add -g firestack-cli

Prerequisites

Requirement Purpose
Firebase CLI API access β€” npm i -g firebase-tools
firebase login Authenticate before running setup
Node.js β‰₯ 18 Runtime

πŸš€ Quick Start

From the root of your project:

npx firestack-cli setup

The CLI auto-detects your framework and guides you through every step:

πŸ”₯ Firebase Setup CLI for Web, React Native & Expo

βœ” Project analyzed
  Framework: Next.js (App Router)
  Package manager: bun
  TypeScript: yes

βœ” Firebase CLI v15.8.0 found
βœ” Authenticated as you@example.com

? Select a Firebase project to connect: β€Ί my-awesome-app
? Which Firebase services do you want to initialize in code?
  βœ” Authentication (auth)
  βœ” Cloud Firestore (db)
  βœ” Cloud Storage (storage)

β—† Configuring Firebase for Next.js (App Router)
βœ” Created .env.local with NEXT_PUBLIC_FIREBASE_* variables
βœ” Firebase client initialized at src/lib/firebase.ts

β—† Dependency Management
βœ” Installed missing dependencies (firebase)

πŸŽ‰ Firebase configuration complete!

🧩 Commands

Command Description
firestack setup Interactive Firebase setup wizard
firestack doctor Diagnose configuration & env issues (read-only)
firestack fix Auto-fix all detected problems
firestack fix env Fix environment variables (.env.local / .env)
firestack fix web Fix Web / JS SDK configuration
firestack fix android Fix Android native configuration
firestack fix ios Fix iOS native configuration
firestack fix deps Install missing Firebase dependencies
firestack --help Show help
firestack --version Show version

🧠 How It Works

1 Β· Multi-Framework Detection

firestack-cli inspects your project before making changes:

  • Framework β€” Next.js (App / Pages router), Expo (with Expo Router), Vite, CRA, Remix, Astro, SvelteKit, Bare React Native
  • Package manager β€” Bun, npm, pnpm, or Yarn
  • Environment format β€” .env.local (Next.js) or .env (Vite/Expo) with appropriate variable prefixes
  • Native folders β€” android/ and ios/ presence for mobile builds
  • Firebase services β€” Auth, Firestore, Storage, Realtime DB, and Analytics

2 Β· Environment Variables & Client Boilerplate

  • Generates .env.local or .env: Safely appends or updates FIREBASE_* credentials while preserving all your existing non-Firebase environment variables.
  • Generates Type-Safe Client Module: Creates src/lib/firebase.ts (or .js) with singleton guards and typed exports for auth, db, storage, and analytics.

3 Β· Native Mobile Configuration (Expo & Bare RN)

  • Android: Downloads google-services.json, patches build.gradle classpath inside buildscript {}, applies plugin in android/app/build.gradle.
  • iOS: Downloads GoogleService-Info.plist, places it in Xcode target folders, and updates app.json.
  • Expo Prebuild: Detects missing native folders and offers to run expo prebuild --no-install.

🩺 Doctor & Fix

Doctor β€” read-only diagnostics

npx firestack-cli doctor
πŸ”₯ Firebase Doctor

Project
  βœ” Framework: Next.js (App Router) (bun)
  βœ” Firebase CLI: Installed (v15.8.0)
  βœ” Firebase authentication: Authenticated as you@example.com

Environment
  βœ” .env.local: Environment configuration file found

Web
  βœ” Firebase configuration: Configuration module found (src/lib/firebase.ts)

Dependencies
  βœ” firebase (JS SDK): Installed

No problems detected! Your Firebase setup is healthy.

Fix β€” automated remediation

npx firestack-cli fix          # fix all issues
npx firestack-cli fix env      # fix .env / .env.local variables
npx firestack-cli fix web      # fix client boilerplate
npx firestack-cli fix android  # fix Android native
npx firestack-cli fix ios      # fix iOS native
npx firestack-cli fix deps     # install missing packages

πŸ›‘οΈ Safety Principles

  • No passwords β€” uses official firebase login OAuth session
  • No silent overwrites β€” existing google-services.json and GoogleService-Info.plist are backed up as .bak before replacement
  • Env safety β€” .env.local and .env parsing preserves all existing environment variables
  • No shell injection β€” all subprocess execution uses shell: false with argument validation
  • Path traversal protection β€” paths from app.json are validated against root boundary
  • Idempotent β€” running setup multiple times never duplicates Gradle plugins or env keys

πŸ§ͺ Development & Testing

# Clone
git clone https://github.com/THARUN-BART/firestack-cli.git
cd firestack-cli

# Install
bun install

# Run tests (44 tests across 7 suites)
bun test

# Build for distribution
bun run build

πŸ“„ License

MIT Β© Tharun Poongavanam


npm Β· GitHub Β· Issues

Made with ❀️ for the Web & Mobile React community

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages