Overview
The Firebase configuration module initializes Firebase services and exports authentication and Firestore database instances used throughout the application.
Source: public/js/firebase.js
Firebase SDK Imports
StockPro uses Firebase JavaScript SDK v10.12.2 from CDN:
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
import { getAuth } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-auth.js";
import { getFirestore } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-firestore.js";
Initializes a Firebase app instance with the provided configuration
Returns the Firebase Authentication service instance
Returns the Cloud Firestore service instance
Firebase Configuration Object
The application uses the following Firebase project configuration:
const firebaseConfig = {
apiKey: "AIzaSyCK79FXbS3tNPL8V6C03HOMyrr8-rp6YO4",
authDomain: "autopartes-hessman-68283.firebaseapp.com",
projectId: "autopartes-hessman-68283",
storageBucket: "autopartes-hessman-68283.firebasestorage.app",
messagingSenderId: "854961822123",
appId: "1:854961822123:web:75d5b5d3d3e567761e9aee",
measurementId: "G-ENNB0G1JME"
};
Configuration Parameters
Firebase API key for client authentication
Domain for Firebase Authentication redirects
Unique identifier for the Firebase project
Sender ID for Firebase Cloud Messaging
Unique application identifier
Google Analytics measurement ID
Service Initialization
Firebase services are initialized and exported as singleton instances:
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);
export { auth, db };
Exported Services
Firebase Authentication service instance. Use this for all authentication operations including sign-in, sign-out, and auth state monitoring.
Cloud Firestore database instance. Use this for all database operations including reading and writing documents.
Usage in Other Modules
Import the auth and db services in any JavaScript module:
import { auth, db } from "./firebase.js";
// Use auth for authentication
// Use db for Firestore operations
Complete Source Code
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
import { getAuth } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-auth.js";
import { getFirestore } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-firestore.js";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyCK79FXbS3tNPL8V6C03HOMyrr8-rp6YO4",
authDomain: "autopartes-hessman-68283.firebaseapp.com",
projectId: "autopartes-hessman-68283",
storageBucket: "autopartes-hessman-68283.firebasestorage.app",
messagingSenderId: "854961822123",
appId: "1:854961822123:web:75d5b5d3d3e567761e9aee",
measurementId: "G-ENNB0G1JME"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);
export { auth, db };