📖 Scenario: You are building a simple Firebase project to understand how different Firebase services work together. This project will help you set up basic Firebase services and see how they connect in a real app.
🎯 Goal: Create a Firebase project configuration with initial services setup including Authentication, Firestore database, and Cloud Storage. You will define the project data, add configuration variables, implement core service initialization, and finalize the Firebase app setup.
📋 What You'll Learn
Create a Firebase configuration dictionary with exact keys and values
Add a variable for Firebase project ID
Initialize Firebase services using the configuration
Complete the Firebase app initialization with all services connected
💡 Why This Matters
🌍 Real World
Firebase is widely used to build mobile and web apps with backend services like authentication, database, and storage without managing servers.
💼 Career
Understanding Firebase services setup is essential for roles in cloud development, mobile app development, and backend engineering using serverless platforms.
Progress0 / 4 steps
1
Create Firebase configuration dictionary
Create a dictionary called firebase_config with these exact entries: apiKey set to "AIzaSyA-1234567890abcdef", authDomain set to "myapp.firebaseapp.com", projectId set to "myapp-12345", storageBucket set to "myapp.appspot.com", messagingSenderId set to "1234567890", and appId set to "1:1234567890:web:abcdef123456".
Firebase
Hint
Use a Python dictionary with the exact keys and string values as shown.
2
Add Firebase project ID variable
Create a variable called project_id and set it to the string "myapp-12345".
Firebase
Hint
Assign the exact string to the variable project_id.
3
Initialize Firebase services
Write code to initialize Firebase Authentication, Firestore, and Storage services using the firebase_config dictionary. Use variables named auth, db, and storage respectively.
Firebase
Hint
Assign strings indicating initialization to auth, db, and storage variables to simulate service setup.
4
Complete Firebase app setup
Create a variable called firebase_app and set it to a dictionary containing the keys "config", "auth", "db", and "storage" with their corresponding variables firebase_config, auth, db, and storage as values.
Firebase
Hint
Combine all previous variables into one dictionary named firebase_app.
Practice
(1/5)
1. Which Firebase service helps you manage user sign-in and identity verification easily?
easy
A. Analytics
B. Firestore
C. Authentication
D. Hosting
Solution
Step 1: Understand Firebase services purpose
Authentication is designed to handle user sign-in and identity verification.
Step 2: Match service to function
Firestore is for database, Hosting is for web hosting, Analytics is for tracking usage.
Final Answer:
Authentication -> Option C
Quick Check:
User sign-in = Authentication [OK]
Hint: User sign-in? Think Authentication service [OK]
Common Mistakes:
Confusing Firestore with Authentication
Thinking Hosting manages users
Mixing Analytics with sign-in
2. Which of the following is the correct way to initialize Firebase Hosting in your project?
easy
A. firebase init hosting
B. firebase start hosting
C. firebase deploy hosting
D. firebase create hosting
Solution
Step 1: Recall Firebase CLI commands
To set up Hosting, you first initialize it with firebase init hosting.
Step 2: Differentiate commands
firebase deploy hosting deploys but does not initialize; others are invalid commands.
Final Answer:
firebase init hosting -> Option A
Quick Check:
Initialize Hosting = firebase init hosting [OK]
Hint: Init means setup, so use 'firebase init hosting' [OK]
Common Mistakes:
Using deploy before init
Using non-existent commands
Confusing start with init
3. What will the following Firebase code snippet do?
const db = firebase.firestore();
db.collection('users').add({name: 'Anna', age: 25});
medium
A. Update existing user document named Anna with age 25
B. Add a new user document with name Anna and age 25 to Firestore
C. Delete user document named Anna from Firestore
D. Retrieve all users named Anna from Firestore
Solution
Step 1: Understand Firestore collection and add method
The add method creates a new document in the 'users' collection with given data.
Step 2: Analyze code effect
The code adds a new user with name 'Anna' and age 25; it does not update, delete, or retrieve.
Final Answer:
Add a new user document with name Anna and age 25 to Firestore -> Option B
Quick Check:
add() creates new document = Add a new user document with name Anna and age 25 to Firestore [OK]
Hint: add() means create new document in Firestore [OK]
Common Mistakes:
Thinking add updates existing data
Confusing add with get or delete
Assuming it retrieves data
4. You tried to deploy your Firebase Hosting but got an error saying "No public directory found." What is the most likely cause?
medium
A. You did not install Firebase CLI
B. You did not create a Firestore database
C. Your internet connection is down
D. You forgot to specify the public directory during firebase init hosting
Solution
Step 1: Understand the error message context
The error "No public directory found" means Firebase cannot find the folder with website files to deploy.
Step 2: Identify cause related to initialization
This usually happens if you did not set or create the public directory path during firebase init hosting.
Final Answer:
You forgot to specify the public directory during firebase init hosting -> Option D
Quick Check:
Missing public directory = You forgot to specify the public directory during firebase init hosting [OK]
Hint: Set public directory when initializing Hosting [OK]
Common Mistakes:
Blaming internet connection
Confusing Firestore with Hosting
Not installing Firebase CLI
5. You want to track how users interact with your app and also store user profiles. Which two Firebase services should you combine?
hard
A. Firestore and Analytics
B. Hosting and Cloud Functions
C. Authentication and Hosting
D. Realtime Database and Storage
Solution
Step 1: Identify service for storing user profiles
Firestore is a database service suitable for storing structured user profile data.
Step 2: Identify service for tracking user interactions
Analytics tracks user behavior and app usage statistics.
Final Answer:
Firestore and Analytics -> Option A
Quick Check:
Store profiles + track usage = Firestore + Analytics [OK]
Hint: Store data with Firestore, track with Analytics [OK]
Common Mistakes:
Choosing Hosting for data storage
Confusing Realtime Database with Analytics
Mixing Storage with tracking
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.