firebase.auth().signOut() in a React app?In a React app using Firebase Authentication, what is the immediate effect of calling firebase.auth().signOut()?
Think about how Firebase updates the authentication state in real-time.
Calling signOut() immediately updates the client authentication state to null, triggering React components listening to auth changes to update accordingly.
Given the Firebase config object, which snippet correctly initializes Firebase in a React app?
const firebaseConfig = {
apiKey: "API_KEY",
authDomain: "PROJECT_ID.firebaseapp.com",
projectId: "PROJECT_ID",
storageBucket: "PROJECT_ID.appspot.com",
messagingSenderId: "SENDER_ID",
appId: "APP_ID"
};Use the modular Firebase SDK syntax for React apps.
The modern Firebase SDK uses named imports like initializeApp from 'firebase/app'. The older default import firebase is deprecated.
You want your React app to show live updates from Firestore. Which architecture pattern is best?
Think about how Firestore provides real-time listeners.
Using onSnapshot inside useEffect allows React components to update state immediately when Firestore data changes, enabling real-time UI updates.
Given a Firestore collection users where each document ID is a user UID, which security rule restricts read access so users can only read their own document?
Check how to compare authenticated user ID with document ID.
Rule D allows read only if the authenticated user's UID matches the document ID, preventing access to others' documents.
Firebase API keys are visible in the React app bundle. What is the best practice to keep your Firebase project secure?
Consider how Firebase API keys are designed and what protects your data.
Firebase API keys are not secret. The best practice is to restrict usage by domain in the Firebase console and enforce security rules to protect data access.