Enable Firebase Firestore for a React Native App
Cloud Firestore stores app data such as users, feeds, chats, products, orders, bookings, listings, reviews, and settings. Enable Firestore before importing seed data or testing screens that read backend data.
Quick Answer
Enable Cloud Firestore in Firebase Console, deploy the Firestore rules and
indexes shipped with your app package when available, import seed data if the
app expects it, then verify reads and writes from the app. Never publish a
production app with public allow read, write: if true rules.
1. Enable Cloud Firestore
- Open Firebase Console.
- Select your Firebase project.
- Go to Firestore Database.
- Create the database.
- Select the region that matches your users and backend functions.
If the console asks for security mode, choose the safer option and deploy your own rules after reviewing the app requirements.
2. Deploy App Rules and Indexes
Many Instamobile app packages include Firebase files:
firebase/
firestore.rules
firestore.indexes.json
From the app's Firebase folder:
firebase login
firebase use --add
firebase deploy --only firestore:rules
firebase deploy --only firestore:indexes
Review the rules before production. The correct rules depend on the app type, the user roles, and the collections you expose to customers.
3. Use Safe Development Rules
If your package does not include Firestore rules yet, start with restrictive development rules and expand collection by collection.
Example authenticated-only starting point:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read: if request.auth != null;
allow write: if request.auth != null && request.auth.uid == userId;
}
match /{document=**} {
allow read, write: if false;
}
}
}
Do not use this as a final production policy. Add role checks, owner checks, validation, and app-specific collection rules before release.
4. Import Seed Data
Some products need seed data for categories, vendors, listings, appointments, or demo content.
Use the seed guide after Firestore is enabled:
5. Verify Firestore From the App
Run a flow that writes data:
- create a test user;
- edit a profile;
- create a post;
- send a chat message;
- create an order, booking, or listing, depending on the app.
Then verify the expected document appears in Firebase Console.
Troubleshooting
| Problem | Fix |
|---|---|
permission-denied | Rules do not allow the current user/action. Check auth state and rules. |
| Missing index error | Open the Firebase error link or deploy firestore.indexes.json. |
| Empty lists after setup | Import seed data or verify the app points to your Firebase project. |
| Writes work in debug but fail in release | Check bundle/package config, App Check enforcement, and production rules. |
| Costs are unexpectedly high | Add query limits, avoid broad listeners, and review indexes and listener usage. |