Firebase Project Setup Guide
Preparing your first Firebase project!
Create a Firebase Account
Visit the Firebase Console.
Sign in with your Google account or create one if you don't have it.
Create a New Project
Click on "Add project" and follow the prompts to name your project.
Configure Google Analytics settings if desired, then click "Create project".
Register Your App
In the Firebase Console, click on the web icon () to set up Firebase for a web app.
Register your app with a nickname and optionally set up Firebase Hosting.
Click "Register app".
Firebase Hosting is optional.Add Firebase SDK to Your Project
After registering, you'll see a setup screen with a Firebase configuration object.
Copy the configuration object, which looks like this:
const firebaseConfig = {
apiKey: "your-api-key",
authDomain: "your-auth-domain",
projectId: "your-project-id",
storageBucket: "your-storage-bucket",
messagingSenderId: "your-messaging-sender-id",
appId: "your-app-id"
};
Install Firebase SDK
In your project directory, run:
npm install firebase
Initialize Firebase in your app with the configuration object:
import { initializeApp } from "firebase/app";
const firebaseApp = initializeApp(firebaseConfig);
Install Firebase CLI (Optional)
If you need to deploy to Firebase Hosting or use other CLI features, install it globally:
npm install -g firebase-tools
Log in and initialize Firebase in your project:
firebase login
firebase init
firebase login will prompt
a login to authenticate the user and grant access to Firebase project via the terminal.
firebase init will guide
the user through selecting and configuring Firebase services for their project.
Deploy Your App (Optional)
If using Firebase Hosting, deploy your app with:
firebase deploy
How my MJS file is setup
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
const firebaseConfig = {
apiKey: "your-api-key",
authDomain: "your-auth-domain",
projectId: "your-project-id",
storageBucket: "your-storage-bucket",
messagingSenderId: "your-messaging-sender-id",
appId: "your-app-id"
};
export const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
I made it like this so I can have 'auth' be exported and used wherever I might need it for
authorizing access and also in my case the other login providers.