Complete the code to import only the Firestore function needed to get a document.
import { getDoc, [1] } from 'firebase/firestore';
The doc function is needed to specify the document reference for getDoc. Importing only what you need helps keep the bundle small.
Complete the code to initialize Firebase app with the modular SDK.
import { initializeApp } from 'firebase/app'; const firebaseConfig = { /* config values */ }; const app = [1](firebaseConfig);
getApp before initializing the app.createApp or startApp.initializeApp is the correct function to start a Firebase app instance with the given configuration.
Fix the error in importing Firestore functions for reading a document.
import { getDoc, doc, [1] } from 'firebase/firestore';
getDoc twice.initializeApp from Firestore instead of 'firebase/app'.The collection function is often needed to create references to collections, which is useful when navigating Firestore structure. Importing getDoc twice is redundant and causes errors.
Fill both blanks to create a Firestore document reference and read it.
import { getFirestore, [1], [2] } from 'firebase/firestore'; const db = getFirestore(app); const docRef = [1](db, 'users', 'user123'); const docSnap = await [2](docRef);
collection instead of doc for document references.getDoc and getDocs.doc creates a reference to a specific document. getDoc reads the document data. Using these two functions together is the modular way to read a Firestore document.
Fill all three blanks to import, initialize, and get a Firestore document using modular SDK.
import { [1] } from 'firebase/app'; import { getFirestore, [2], [3] } from 'firebase/firestore'; const app = [1](firebaseConfig); const db = getFirestore(app); const docRef = [2](db, 'products', 'prod001'); const docSnap = await [3](docRef);
initializeApp incorrectly.collection instead of doc for document references.getDoc with getDocs.First, initializeApp starts the Firebase app. Then doc creates a document reference. Finally, getDoc reads the document data. This sequence uses modular imports to keep the code efficient.