{"id":10894,"library":"firebase","title":"Firebase JavaScript SDK","description":"The Firebase JavaScript SDK provides a comprehensive client-side library for interacting with Google's Firebase platform, suitable for web, mobile-web (e.g., React Native, Ionic), and Node.js desktop (e.g., Electron) applications. The current stable version is 12.12.0, with minor versions released frequently, often weekly or bi-weekly, reflecting continuous development and updates across its sub-packages. It offers a suite of services including Authentication, Cloud Firestore, Realtime Database, Cloud Storage, Cloud Functions, Messaging, Performance Monitoring, Analytics, Remote Config, App Check, and AI capabilities. A key differentiator since version 9 is its modular, tree-shakable API, which significantly improves application bundle sizes. This SDK is distinct from the Firebase Admin Node.js SDK, which is designed for privileged server environments and administrative access.","status":"active","version":"12.12.0","language":"javascript","source_language":"en","source_url":"https://github.com/firebase/firebase-js-sdk","tags":["javascript","authentication","database","Firebase","firebase","realtime","storage","performance","remote-config","typescript"],"install":[{"cmd":"npm install firebase","lang":"bash","label":"npm"},{"cmd":"yarn add firebase","lang":"bash","label":"yarn"},{"cmd":"pnpm add firebase","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Firebase Auth in React Native environments, requiring v2+","package":"react-native-async-storage","optional":false}],"imports":[{"note":"Since v9, Firebase uses a modular API for tree-shaking. Import specific functions from service modules, not the top-level 'firebase' package directly for services.","wrong":"const firebase = require('firebase/app');\nimport firebase from 'firebase';","symbol":"initializeApp","correct":"import { initializeApp } from 'firebase/app';"},{"note":"Individual service functions like `getAuth()` are imported from their respective modular paths. The compat API (e.g., `firebase/compat/auth`) still exists but is not tree-shakable.","wrong":"import firebase from 'firebase/auth'; // Incorrect modular import\nimport { auth } from 'firebase'; // Old compat API pattern","symbol":"getAuth","correct":"import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';"},{"note":"Follow the modular pattern for all services. Each service (Firestore, Realtime Database, Storage, etc.) has its own entry point.","wrong":"const firestore = require('firebase/firestore').firestore; // CommonJS with modular API\nimport { firestore } from 'firebase'; // Old compat API pattern","symbol":"getFirestore","correct":"import { getFirestore, collection, addDoc } from 'firebase/firestore';"},{"note":"TypeScript types for various Firebase objects are available directly from the service modules.","symbol":"Auth types","correct":"import type { User } from 'firebase/auth';"}],"quickstart":{"code":"import { initializeApp } from 'firebase/app';\nimport { getFirestore, collection, addDoc } from 'firebase/firestore';\n\n// TODO: Replace the following with your app's Firebase project configuration\nconst firebaseConfig = {\n  apiKey: \"YOUR_API_KEY\",\n  authDomain: \"YOUR_PROJECT_ID.firebaseapp.com\",\n  projectId: \"YOUR_PROJECT_ID\",\n  storageBucket: \"YOUR_PROJECT_ID.appspot.com\",\n  messagingSenderId: \"YOUR_MESSAGING_SENDER_ID\",\n  appId: \"YOUR_APP_ID\",\n  // Optional: measurementId: \"G-XXXXXXXXXX\"\n};\n\nasync function initializeAndAddData() {\n  try {\n    const app = initializeApp(firebaseConfig);\n    console.log(\"Firebase app initialized successfully.\");\n\n    const db = getFirestore(app);\n    const docRef = await addDoc(collection(db, \"users\"), {\n      first: \"Ada\",\n      last: \"Lovelace\",\n      born: 1815\n    });\n    console.log(\"Document written with ID: \", docRef.id);\n  } catch (error: any) {\n    console.error(\"Error initializing Firebase or adding document:\", error.message);\n  }\n}\n\ninitializeAndAddData();\n","lang":"typescript","description":"Initializes a Firebase app and demonstrates adding a document to Cloud Firestore using the modular API."},"warnings":[{"fix":"Migrate your application to the modular API by importing specific functions from service modules (e.g., 'firebase/app', 'firebase/auth') and using functional patterns (e.g., getAuth(), signInWithEmailAndPassword()). Refer to the Firebase 'Upgrade to Version 9' guide.","message":"Version 9 introduced a completely redesigned modular API to enable tree-shaking and reduce bundle sizes. The previous 'compat' API still works but is not tree-shakable.","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Users of `@firebase/ai` should plan to migrate their applications to alternative AI models or services by June 2026. Consult Firebase documentation for recommended replacements.","message":"All Imagen models provided by the `@firebase/ai` package are officially deprecated and will be shut down as early as June 2026.","severity":"deprecated","affected_versions":">=12.11.0"},{"fix":"Instead of the deprecated methods, use the new methods that have been added to the `LiveSession` class for streaming media. Review the `@firebase/ai` changelog for the specific new API.","message":"The `sendMediaChunks()` and `sendMediaStream()` methods within the `@firebase/ai` package's `LiveSession` class have been deprecated.","severity":"deprecated","affected_versions":">=12.5.0"},{"fix":"Ensure `react-native-async-storage` is installed and updated to version 2 or higher in your React Native project when using Firebase Auth. Run `npm install --save react-native-async-storage@^2.0.0` or `yarn add react-native-async-storage@^2.0.0`.","message":"Firebase Authentication for React Native now requires `react-native-async-storage` v2+ as a peer dependency, which may require an update to your `package.json`.","severity":"gotcha","affected_versions":">=12.7.0"}],"env_vars":null,"search_vec":"'12.12.0':43 '9':97 'access':130 'across':60 'admin':118 'administr':129 'ai':90 'analyt':84 'api':104 'app':87 'applic':37,108 'authent':72,132 'bi':53 'bi-week':52 'bundl':109 'capabl':91 'check':88 'client':12 'client-sid':11 'cloud':73,77,79 'comprehens':10 'config':86,141 'continu':56 'current':39 'databas':76,133 'design':123 'desktop':34 'develop':57 'differenti':94 'distinct':114 'e.g':28,35 'electron':36 'environ':127 'firebas':1,5,20,117,134,135 'firestor':74 'frequent':48 'function':80 'googl':18 'improv':107 'includ':71 'interact':16 'ionic':31 'javascript':2,6,131 'key':93 'librari':14 'messag':81 'minor':45 'mobil':26 'mobile-web':25 'modular':100 'monitor':83 'nativ':30 'node.js':33,119 'offer':66 'often':49 'packag':64 'perform':82,138 'platform':21 'privileg':125 'provid':8 'react':29 'realtim':75,136 'reflect':55 'releas':47 'remot':85,140 'remote-config':139 'sdk':3,7,112,120 'server':126 'servic':70 'shakabl':103 'side':13 'signific':106 'sinc':95 'size':110 'stabl':40 'storag':78,137 'sub':63 'sub-packag':62 'suit':68 'suitabl':22 'tree':102 'tree-shak':101 'typescript':142 'updat':59 'version':41,46,96 'web':24,27 'week':50,54","created_at":"2026-04-19T13:35:10.866125+00:00","updated_at":"2026-04-19T13:35:10.866125+00:00","problems":[{"fix":"Ensure `initializeApp(firebaseConfig)` is called once at the start of your application's lifecycle before any Firebase service-specific functions are invoked. This call should typically be near your app's entry point.","cause":"Attempting to use a Firebase service (e.g., getAuth(), getFirestore()) before `initializeApp()` has been successfully called.","error":"Firebase: No Firebase App '[DEFAULT]' has been created - call initializeApp() first (app/no-app)."},{"fix":"Verify that your import statements are correct for the modular API (e.g., `import { getAuth } from 'firebase/auth';`). If you intend to use the compat API, explicitly import from `firebase/compat/auth`.","cause":"This error occurs when a bundler or runtime cannot find the expected modular entry point, often due to an incorrect import path or mixing modular imports with the older 'compat' API usage.","error":"Error: Modular code path not found for firebase/auth. Did you mean firebase/compat/auth?"},{"fix":"Switch all Firebase imports to the ES Module syntax (e.g., `import { initializeApp } from 'firebase/app';`). Ensure your bundler configuration (e.g., Webpack, Rollup, Vite) is correctly set up to handle ESM.","cause":"This Webpack-specific error (or similar from other bundlers) often arises when using `require('firebase/app')` or an older CommonJS pattern in a project configured for ES Modules (ESM) with the modern Firebase SDK.","error":"TypeError: __webpack_require__.i(...) is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.0.1","cli_name":"","cli_version":null,"type":"library","homepage":"https://firebase.google.com","github":"https://github.com/firebase/firebase-js-sdk","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/firebase","openapi_spec":null,"status_page":null,"smithery":null,"categories":["gcp","database","auth-security","communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}