Firestore
Firestore
Cloud Firestore is a flexible, scalable NoSQL document database from Firebase, allowing React Native applications to store, sync, and query structured data in real time.
Installing Firestore
bash
npm install @react-native-firebase/firestore
Adding a Document
javascript
import firestore from '@react-native-firebase/firestore';
await firestore().collection('users').add({
name: 'John Doe',
email: 'john@example.com',
});
Reading a Single Document
javascript
const doc = await firestore().collection('users').doc(userId).get();
console.log(doc.data());
Querying a Collection
javascript
const snapshot = await firestore()
.collection('products')
.where('category', '==', 'electronics')
.get();
const products = snapshot.docs.map((doc) => ({ id: doc.id, ...doc.data() }));
Real-Time Listeners
javascript
useEffect(() => {
const subscriber = firestore()
.collection('messages')
.onSnapshot((snapshot) => {
const messages = snapshot.docs.map((doc) => doc.data());
setMessages(messages);
});
return subscriber;
}, []);
Updating and Deleting Documents
javascript
await firestore().collection('users').doc(userId).update({ name: 'Updated Name' });
await firestore().collection('users').doc(userId).delete();
Structuring Firestore Data
Firestore data is organized into collections and documents, with subcollections allowing nested relationships, requiring thoughtful structure planning for efficient queries.
Conclusion
Cloud Firestore’s real-time synchronization and flexible querying capabilities make it a powerful choice for building data-driven, live-updating React Native applications.

