package
Firebase JavaScript library for web and Node.js
npm install firebaseGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Latest published Nov 11, 2026
eap-sql
latest
eap-crashlytics
feiyang.chen
feiyang.chen1@gmail.com
Version 9 has a redesigned API that supports tree-shaking. Read the Upgrade Guide to learn more.
Firebase provides the tools and infrastructure you need to develop, grow, and earn money from your app. This package supports web (browser), mobile-web, and server (Node.js) clients.
For more information, visit:
This SDK is intended for end-user client access from environments such as the Web, mobile Web (e.g. React Native, Ionic), Node.js desktop (e.g. Electron), or IoT devices running Node.js. If you are instead interested in using a Node.js SDK which grants you admin access from a privileged environment (like a server), you should use the Firebase Admin Node.js SDK.
Install the Firebase NPM module:
$ npm init
$ npm install --save firebaseimport { initializeApp } from 'firebase/app';
// TODO: Replace the following with your app's Firebase project configuration
const firebaseConfig = {
//...
};
const app = initializeApp(firebaseConfig);Firebase services (like Cloud Firestore, Authentication, Realtime Database, Remote Config, and more) are available to import within individual sub-packages.
The example below shows how you could use the Cloud Firestore Lite SDK to retrieve a list of data.
import { initializeApp } from 'firebase/app';
import { getFirestore, collection, getDocs } from 'firebase/firestore/lite';
// Follow this pattern to import other Firebase services
// import { } from 'firebase/<service>';
// TODO: Replace the following with your app's Firebase project configuration
const firebaseConfig = {
//...
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
// Get a list of cities from your database
async function getCities(db) {
const citiesCol = collection(db, 'cities');
const citySnapshot = await getDocs(citiesCol);
The Firebase Web SDK is designed to work with module bundlers to remove any unused code (tree-shaking). We strongly recommend using this approach for production apps. Tools such as the Angular CLI, Next.js, Vue CLI, or Create React App automatically handle module bundling for libraries installed through npm and imported into your codebase.
See Using module bundlers with Firebase for more information.
You can also load Firebase packages as script modules in browsers that support native ES modules.
<!-- use script module by specifying type="module" -->
<script type="module">
import { initializeApp } from 'https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-app.js';
import { getFirestore, collection, getDocs } from 'https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-firestore-lite.js';
// Follow this pattern to import other Firebase services
// import {} from "https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-analytics.js";
// import {} from "https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-app-check.js";
// import {} from "https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-auth.js";
// import {} from "https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-functions.js";
// import {} from "https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-firestore.js";
// import {} from "https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-storage.js";
// import {} from "https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-performance.js";
// import {} from "https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-remote-config.js";
// import {} from "https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-messaging.js";
// import {} from "https://www.gstatic.com/firebasejs/${FIREBASE_VERSION}/firebase-database.js";
Note: To get a filled in version of the above code snippet, go to the Firebase console for your app and click on "Add Firebase to your web app".
While you can write entire Firebase applications without any backend code, many developers want to write server applications or command-line utilities using the Node.js JavaScript runtime.
You can use the same npm module to use Firebase in the Node.js runtime (on a server or running from the command line):
$ npm init
$ npm install --save firebaseIn your code, you can access Firebase using:
const { initializeApp } = require('firebase/app');
const { getFirestore, collection, getDocs } = require('firebase/firestore');
// ...If you are using native ES6 module with --experimental-modules flag (or Node 12+) you should do:
import { initializeApp } from 'firebase/app';
import { getFirestore, collection, getDocs } from 'firebase/firestore';
// ...Please see Environment Support for which packages are available in Node.js.
Version 9 provides a set of compat packages that are API compatible with Version 8. They are intended to be used to make the upgrade to the modular API easier by allowing you to upgrade your app piece by piece. See the Upgrade Guide for more detail.
To access the compat packages, use the subpath compat like so:
// v9 compat packages are API compatible with v8 code
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';The Firebase changelog can be found at firebase.google.com.
Please see Environment Support.
The Firebase type declarations require TypeScript 4.5 or later. With an older version, TypeScript reports "has no exported member" errors for the names you import from Firebase, and this error:
Type '"Please upgrade TypeScript"' is not assignable to type '"firebase requires TypeScript 4.5 or later"'.TypeScript leaves out this error if any type declarations fail to parse. Some
Firebase dependencies install the latest version of @types/node, which can be
too new for your version of TypeScript. If you see syntax errors in
@types/node, upgrade TypeScript, or install a version of @types/node that
supports your version of TypeScript.
Estimated unpacked size across 64 packages.
161.4 MB+
Includes dependencies.
29 direct dependencies.
3.1.0
3.1.0
0.16.6
0.16.6
1.13.10
1.13.10
1.15.3
1.15.3
0.14.6
0.14.6
0.9.6
0.9.6
4.20.0
4.20.0
0.14.0
0.14.0
0.13.3
0.13.3
0.5.22
0.5.22
0.6.15
0.6.15
0.1.1
0.7.14
0.7.14
0.7.4
0.6.24
0.6.24
0.10.0
0.10.0
0.4.6
2.1.8
0.2.31
0.4.7
0.4.18
0.5.0
0.2.30
0.2.27
0.2.24
0.2.31