Firebase SDKs Overview
An SDK — Software Development Kit — is a collection of code that lets your app talk to Firebase. Without an SDK, your code would need to manually send raw HTTP requests to Firebase servers, which is complex and error-prone. The Firebase SDK wraps all that complexity into clean, readable functions.
The SDK as a Remote Control
Think of Firebase services as a smart television. You could reach inside the TV and press physical buttons on the circuit board. Or you could use a remote control — a device built specifically to operate the TV from a comfortable distance. The Firebase SDK is your remote control. It gives you easy buttons for database reads, user logins, file uploads, and more, without you needing to understand the internal wiring.
Available Firebase SDKs
Firebase provides SDKs for multiple platforms so the same Firebase project powers all types of apps:
- JavaScript / Web SDK — for websites and web apps built with HTML, CSS, and JavaScript
- Android SDK — for native Android apps written in Kotlin or Java
- iOS SDK — for native iPhone and iPad apps written in Swift or Objective-C
- Flutter SDK — for cross-platform apps built with Flutter and Dart
- Unity SDK — for games built in the Unity engine
- Admin SDK — for server-side code in Node.js, Python, Java, or Go
This course focuses on the JavaScript Web SDK, which works in any web browser and in Node.js environments.
Modular vs Compat SDK
The Firebase Web SDK comes in two flavors: modular (version 9+) and the older compat style. Understanding the difference matters because you will see both in tutorials and documentation.
Modular SDK (Recommended)
The modular SDK uses a tree-shakeable import style. Tree-shaking means your final app bundle only includes the Firebase code your app actually uses, making the app smaller and faster.
// Modular style — import only what you need
import { initializeApp } from "firebase/app";
import { getAuth, signInWithEmailAndPassword } from "firebase/auth";
import { getFirestore, doc, getDoc } from "firebase/firestore";
Compat SDK (Legacy)
The compat SDK uses chained method calls that look different from the modular style. It exists to help developers migrate older code without rewriting everything at once.
// Compat style — older way of writing Firebase code const auth = firebase.auth(); auth.signInWithEmailAndPassword(email, password);
Always use the modular SDK for new projects. The compat style still works, but the modular style produces faster apps and receives new features first.
How to Install the Web SDK
Firebase installs through npm, the Node.js package manager. Open a terminal in your project folder and run:
npm install firebase
This downloads the entire Firebase SDK package to your project. You then import only the specific parts you need in each file — you do not need to import the whole SDK at once.
Using Firebase via CDN (No Installation)
For simple HTML pages or quick tests, you can load Firebase directly from Google's CDN without installing anything. Add script tags to your HTML file:
<!-- Firebase App (core) -->
<script type="module">
import { initializeApp } from
"https://www.gstatic.com/firebasejs/10.0.0/firebase-app.js";
import { getFirestore } from
"https://www.gstatic.com/firebasejs/10.0.0/firebase-firestore.js";
</script>
This approach works for learning and prototyping. For production apps, use the npm installation instead so you control your dependency versions.
Initializing Firebase in Your App
Before calling any Firebase function, you must initialize the Firebase app with your configuration object. This tells the SDK which project to connect to.
import { initializeApp } from "firebase/app";
const firebaseConfig = {
apiKey: "AIzaSy...",
authDomain: "my-app.firebaseapp.com",
projectId: "my-app-12345",
storageBucket: "my-app-12345.appspot.com",
messagingSenderId: "123456789",
appId: "1:123456789:web:abcdef"
};
// Initialize once, at the start of your app
const app = initializeApp(firebaseConfig);
Run initializeApp only once. If you call it multiple times with the same project, Firebase throws an error. Most developers put this initialization in a dedicated file — often called firebase.js — and import the initialized app from there throughout the project.
Getting Service Instances
After initialization, you get a service instance for each Firebase feature you use. Each service has its own getter function:
import { getAuth } from "firebase/auth";
import { getFirestore } from "firebase/firestore";
import { getStorage } from "firebase/storage";
const auth = getAuth(app); // Authentication service
const db = getFirestore(app); // Firestore database service
const storage = getStorage(app); // Cloud Storage service
These service instances are what you pass to all other Firebase functions. They are lightweight references — getting them does not immediately connect to Firebase or charge you for usage.
The Admin SDK
The Admin SDK runs on a server, not in a browser. It bypasses security rules and has full access to your Firebase project. Use it in trusted environments — like Cloud Functions or your own server — never in browser-facing code.
// Admin SDK — server-side only
const admin = require("firebase-admin");
admin.initializeApp();
// Full access to Firestore, Auth, and Storage
const db = admin.firestore();
The Admin SDK is useful for tasks like sending mass notifications, deleting user accounts, or importing data — operations that require elevated permissions.
SDK Version Management
Firebase releases regular updates. Check your installed version with:
npm list firebase
Update to the latest version with:
npm update firebase
Read the Firebase changelog before major updates. Most updates add features without breaking existing code, but major version changes sometimes require small code adjustments.
Key Takeaway
The Firebase SDK connects your app code to Firebase services without dealing with raw server requests. Use the modular SDK for web projects — import only what your app needs. Initialize Firebase once with your config object, get service instances for each feature you use, and keep your SDK version updated. For server-side tasks that need elevated permissions, use the Admin SDK in a trusted server environment.
