firekeys
v1.0.0
Published
Convert Firebase config from JavaScript/JSON to .env format
Downloads
128
Maintainers
Readme
firekeys
I got tired of copying and pasting Firebase config into my Next.js apps, so I made this small CLI. It turns your Firebase config (and service account keys) into .env format automatically.
Next.js is the supported target (e.g. NEXT_PUBLIC_FIREBASE_* for client config). If you want support for other frameworks or platforms, open an issue and we can add it.
It handles both:
- Client config — the
firebaseConfigobject from the Firebase console →.envwithNEXT_PUBLIC_vars - Service account keys — your admin SDK JSON →
FIREBASE_PROJECT_ID,FIREBASE_CLIENT_EMAIL,FIREBASE_PRIVATE_KEY
Installation
npm install -g firekeys
# or
npx firekeysUsage
Client SDK config (JavaScript)
# From argument (use single quotes so inner " work)
firekeys 'const firebaseConfig = { apiKey: "AIza...", authDomain: "...", projectId: "...", storageBucket: "...", messagingSenderId: "...", appId: "1:..." };'
# From file
firekeys config.js
# From stdin (paste then Ctrl+D)
firekeys
# Custom output file
firekeys config.js -o .env.localAdmin SDK config (JSON)
firekeys admin-key.json --pp
cat admin-key.json | firekeys --ppOutput format
Client: NEXT_PUBLIC_FIREBASE_API_KEY, NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN, etc.
Admin: FIREBASE_PROJECT_ID, FIREBASE_CLIENT_EMAIL, FIREBASE_PRIVATE_KEY
Publishing to npm
cd firebasekeys-node
npm login
npm publishAfter publish, users install with: npm install -g firekeys
