Enable Firebase Firestore

Create a Firestore database and write security rules that let your app read and write safely.

A React Native app backed by Firebase usually stores its data in Firestore. This guide covers creating the database and setting rules that let your app actually read and write.

Quick Answer

In Firebase Console → Firestore Database, create a database, choose a region close to your users, start with test-mode rules while developing, then replace them with real security rules before launch.

1. Create the Database

Firestore Database → Create database. Pick a region close to your primary users; this can't be changed later without migrating data.

2. Test-Mode Rules (development only)

Test mode allows all reads and writes until a fixed date. It's fine while developing and must never reach production:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.time < timestamp.date(2026, 12, 31);
    }
  }
}

3. Real Security Rules

Scope access to the authenticated user and to the collections your app actually needs. A minimal example where users can only touch their own document:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{userId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }
  }
}

Rules are not filters. A query that could return documents the rules forbid fails entirely rather than returning a subset, so write queries and rules to match each other.

4. Deploy Rules and Indexes

If your project keeps rules and indexes in source control:

firebase deploy --only firestore:rules,firestore:indexes

Common Issues

permission-denied on every request rules don't allow the operation. Use the Rules Playground with the exact user and path to see why.

A query fails with a missing-index error Firestore needs a composite index for that query shape. The error message includes a direct console link that creates it.

Data doesn't appear after a write confirm the write didn't silently throw, and that you're looking at the same project the app is configured against.

Verification Checklist

  • the database exists in the intended region;
  • rules are scoped to authenticated users, not left open, before launch;
  • a write from the app appears in the Firestore console;
  • required composite indexes exist.

Next Steps