Skip to main content

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

  1. Open Firebase Console.
  2. Select your Firebase project.
  3. Go to Firestore Database.
  4. Create the database.
  5. 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

ProblemFix
permission-deniedRules do not allow the current user/action. Check auth state and rules.
Missing index errorOpen the Firebase error link or deploy firestore.indexes.json.
Empty lists after setupImport seed data or verify the app points to your Firebase project.
Writes work in debug but fail in releaseCheck bundle/package config, App Check enforcement, and production rules.
Costs are unexpectedly highAdd query limits, avoid broad listeners, and review indexes and listener usage.

Next Steps