T2L
App Development

React Native Private Chat: Building Secure One-to-One Messaging with Firebase

Nov 27, 2026 • 12 min read

Oleg Romanov

Oleg Romanov

Founder, CEO & Tech Lead

Short answer: You can build a production-grade React Native private chat on Firebase in roughly 6-10 weeks for £25k-£60k. The secure version needs Firebase Auth, a Firestore data model keyed by conversation, strict security rules, and Cloud Functions for every sensitive action. Client-side checks alone are not security. Firebase is a strong fit up to a few hundred thousand monthly active users, after which cost and query limits start to matter.

I'm Oleg Romanov, and I've shipped 40+ products at Time2Launch, several of them messengers. Most chat tutorials get a demo working in an afternoon and stop there. This article covers what comes after: the parts that decide whether your private chat is actually private, and whether it survives its first 10,000 users.

Why Firebase for a React Native private chat

For one-to-one messaging, Firebase gives you realtime sync, offline persistence, authentication, push delivery and serverless logic in one SDK family. For a team of two to four engineers, that removes about 3-4 weeks of backend work compared with building WebSockets, a database and a push pipeline yourself.

The trade-offs are real, so here is how the main options compare:

Option Build time (MVP) Realtime Cost at 50k MAU (approx.) Best for
Firebase (Firestore + Functions) 6-10 weeks Built in £150-£600/month Startups, 1:1 chat, fast launch
Custom Node.js + WebSocket + Postgres 12-18 weeks You build it £300-£900/month infra Complex routing, strict data residency
Managed chat SDK (Stream, Sendbird) 3-5 weeks Built in £400-£2,000+/month Teams that want features fast, accept vendor lock-in
Supabase Realtime 7-11 weeks Built in £100-£500/month Teams that prefer SQL and Postgres RLS

These costs depend heavily on message volume and read patterns, so treat them as planning ranges, not quotes. If you're deciding between building and buying, I'd choose a managed SDK when chat is a side feature, and Firebase or custom when chat is the product.

Architecture: the pieces you actually need

A secure private chat on React Native with Firebase has six components:

  • Firebase Authentication (phone, email, Apple, Google) for identity.
  • Cloud Firestore for conversations, messages and user profiles.
  • Security Rules that enforce who can read and write what.
  • Cloud Functions for anything that must not be trusted to the client: creating conversations, blocking, reporting, moderation, counters.
  • Firebase Cloud Messaging (FCM) plus APNs for push notifications.
  • Cloud Storage for images and voice notes, with its own rules.

In React Native, use the @react-native-firebase packages rather than the web JS SDK. They wrap the native iOS and Android SDKs, which gives you better offline persistence, background handling and push reliability.

Designing the Firestore data model

Your data model determines your security rules and your bill. Here is the structure I recommend for one-to-one chat:

users/{uid}
conversations/{conversationId}
  participants: [uidA, uidB]
  lastMessage: { text, senderId, createdAt }
  unread: { uidA: 0, uidB: 2 }
conversations/{conversationId}/messages/{messageId}
  senderId, text, createdAt, type, status
blocks/{uid}/blocked/{otherUid}

Use deterministic conversation IDs

For private one-to-one chats, generate the ID by sorting the two UIDs and joining them (for example uidA_uidB). This guarantees exactly one conversation per pair, prevents duplicates from race conditions, and makes security rules simple, because the rule can check that the requesting UID is part of the document ID.

Keep messages in a subcollection

Putting messages in a subcollection lets you paginate with limit(30) and startAfter, and listen only to the active conversation. Never store messages in an array on the conversation document. Firestore documents cap at 1 MiB, and every update rewrites and re-bills the whole thing.

Denormalise the inbox

The inbox screen needs last message, unread count and the other user's name. Storing lastMessage and unread on the conversation document means the inbox is one query, not N+1. A Cloud Function updates these on every new message.

Security rules: where private chats usually fail

The most common flaw I see in audits is an app that hides other people's chats in the UI but lets any authenticated user query them. The rules are your real perimeter. A baseline for private conversations:

match /conversations/{cid} {
  allow read: if request.auth != null
    && request.auth.uid in resource.data.participants;
  allow create: if false; // created by Cloud Function only

  match /messages/{mid} {
    allow read: if request.auth.uid in
      get(/databases/$(database)/documents/conversations/$(cid)).data.participants;
    allow create: if request.auth.uid in
      get(/databases/$(database)/documents/conversations/$(cid)).data.participants
      && request.resource.data.senderId == request.auth.uid
      && request.resource.data.text.size() <= 4000;
    allow update, delete: if false;
  }
}

Three details matter here:

  • Pin senderId to request.auth.uid. Otherwise a user can send messages as someone else.
  • Validate size and type. Unbounded text fields are an abuse and cost vector.
  • Make messages immutable from the client. Edits and deletes go through a function that logs them.

Note that each get() in a rule counts as a billed document read. At scale, copying the participants list into custom claims or the message document itself can cut that overhead.

Server-side checks for every sensitive action

Security rules are good at access control and weak at business logic. Anything involving more than one document, another user's state, or a policy decision belongs in a Cloud Function (callable or Firestore-triggered):

  • Starting a conversation: check that neither user has blocked the other, that the account is not banned, and that rate limits are respected.
  • Blocking and reporting: write to a moderation queue the client cannot read.
  • Push notifications: send from a onCreate trigger on messages, never from the sending device.
  • Unread counters: update transactionally on the server.
  • Account deletion: cascade-delete or anonymise messages to meet GDPR erasure requests.

Also enable Firebase App Check (Play Integrity on Android, App Attest on iOS). It cuts off scripted abuse from clients that are not your real app, which is the cheapest security improvement available.

Case study: what this looked like in production

We applied exactly this approach on Heelings: React Native Chat App Development with 35% Higher User Engagement. Heelings is a chat app for people who need someone to talk to, which means user safety is not optional. We built it in React Native with Firebase, and every sensitive action is verified on the server, not just in the app. Admins can remove harmful messages and ban users, and the app reached 99.5% crash-free sessions in production on both the App Store and Google Play.

The lesson I took from it: moderation tooling and server-side enforcement are not features you add after launch. We budgeted roughly 20% of the project for them from the start, and that is the ratio I'd recommend for any app where strangers talk to each other.

"In every chat app we've shipped, about 20% of the build goes on server-side enforcement and moderation, and it's the 20% that decides whether the app survives its first 1,000 real users." — Oleg Romanov, Founder, CEO & Tech Lead, Time2Launch

Building the React Native client

Message list performance

Use FlatList with inverted, a stable keyExtractor, and getItemLayout where possible. For long histories, FlashList from Shopify noticeably improves scroll performance on mid-range Android devices. Libraries such as react-native-gifted-chat get you to a working UI in a day, but expect to customise heavily once design requirements arrive.

Optimistic sending and message status

Write the message to local state immediately with a sending status, then let Firestore's offline persistence queue the write. Use the server timestamp (serverTimestamp()) for ordering so clock drift between devices doesn't scramble conversations. Track sent, delivered and read states through lightweight updates, and batch read receipts rather than writing one per message.

Listeners and cost control

Every active snapshot listener is a billing and battery decision:

  • Listen to the inbox query on the inbox screen only.
  • Attach a messages listener only to the open conversation, with a limit of 30-50.
  • Detach listeners on unmount and when the app backgrounds.
  • Use where('createdAt', '>', lastSeen) for incremental sync instead of reloading history.

Push notifications

Use @react-native-firebase/messaging with data-plus-notification payloads. On iOS you need an APNs key uploaded to Firebase; on Android 13+ you must request the POST_NOTIFICATIONS permission at runtime. Budget 3-5 days for push alone: token refresh, deep linking into the right conversation, and badge counts are where bugs hide. Don't put message text in the push payload if the conversation is sensitive, since it will show on lock screens.

Privacy, encryption and compliance

Be precise about what "secure" means. Firebase encrypts data in transit (TLS) and at rest by default. That is not end-to-end encryption: Google infrastructure and your admins can technically read message content.

For most consumer, marketplace and support chats, that's acceptable and necessary, since moderation requires readable content. If you need true E2EE, you'd add the Signal protocol or libsodium on the client, which typically adds 4-8 weeks, makes server-side moderation and search much harder, and complicates multi-device sync. Decide this before you design the data model, not after.

Other compliance items for UK and EU products:

  • GDPR: a lawful basis for processing, a retention policy (for example, delete messages after 24 months), data export and deletion flows.
  • Region selection: choose a Firestore location such as europe-west2 (London) at project creation. You cannot change it later.
  • Child safety: if under-18s can use the app, the ICO's Children's Code and the Online Safety Act apply, and you'll need age assurance and reporting flows.
  • App Store rules: apps with user-generated content require reporting, blocking and a way to remove abusive users (Apple guideline 1.2).

Cost and timeline for a React Native private chat

Realistic numbers for a team of 2-4 engineers plus design and QA:

Scope Timeline Build cost (UK agency) Includes
Basic 1:1 chat MVP 5-7 weeks £20k-£35k Auth, text messages, inbox, push, basic rules
Production-ready secure chat 8-12 weeks £40k-£75k Above plus media, block/report, moderation admin, App Check, tests
Advanced (E2EE, voice/video, multi-device) 16-24 weeks £90k-£180k+ Custom crypto, WebRTC, advanced search and sync

Running costs on Firebase are driven by reads. A typical active user generates 300-1,500 Firestore reads per day depending on how disciplined your listeners are. At Firestore's pay-as-you-go rates (about $0.03 to $0.06 per 100k reads depending on region), 50,000 monthly users usually land in the low hundreds of pounds a month. An undisciplined client with always-on listeners can multiply that by 5-10x, which is why I review listener design before any scale-up.

When Firebase is the wrong choice

I'd steer you away from Firebase when:

  • You need complex relational queries across messages, such as full-text search over millions of messages. Firestore has no native full-text search, so you'd add Algolia or Typesense.
  • You must keep data in a specific jurisdiction beyond what Google's regions offer.
  • You expect millions of daily active users and have a team to run your own infrastructure. Costs can cross over in your favour at that point.
  • Your compliance team requires an auditable, self-hosted environment.

For everything else, especially a startup trying to validate a chat product in a quarter, it's usually the fastest path to something safe and real. If you'd like experienced engineers on it, our React Native mobile app development team has built this pattern repeatedly.

A practical build checklist

  1. Decide E2EE vs server-readable messages. Document the decision.
  2. Choose a Firestore region and create separate dev, staging and prod projects.
  3. Design deterministic conversation IDs and the inbox denormalisation.
  4. Write security rules first, then unit-test them with the Firebase Emulator Suite.
  5. Move conversation creation, blocking, reporting and push to Cloud Functions.
  6. Enable App Check and Crashlytics from day one.
  7. Build the moderation admin tool before launch, not after the first incident.
  8. Load-test listener behaviour on a low-end Android device.
  9. Implement GDPR deletion and export flows.
  10. Set budget alerts in Google Cloud at 50%, 80% and 100% of your expected bill.

Frequently Asked Questions

Is Firebase secure enough for private messaging?

Yes, if you rely on security rules and server-side Cloud Functions rather than client checks. Data is encrypted in transit and at rest, but it is not end-to-end encrypted, so Google and your admins can technically access content.

How long does it take to build a React Native chat app with Firebase?

A basic one-to-one MVP takes 5-7 weeks. A production-ready version with media, block and report features, moderation tools and push notifications typically takes 8-12 weeks.

How much does Firebase cost for a chat app?

For around 50,000 monthly active users, expect roughly £150-£600 per month, mostly Firestore reads. Costs rise sharply if the app keeps unnecessary real-time listeners open.

Should I use Firestore or Realtime Database for chat?

For most new apps, Firestore. It offers richer queries, better scaling and finer-grained security rules. Realtime Database can be cheaper for very high-frequency, simple data, but it is harder to model for inbox and pagination needs.

Can I add end-to-end encryption to a Firebase chat?

Yes, using libsodium or the Signal protocol on the client, with Firebase only transporting ciphertext. Expect 4-8 extra weeks and trade-offs: server-side moderation, search and multi-device sync all become harder.

Do I need moderation tools in a private chat?

If users can message strangers, yes. Apple's App Store guideline 1.2 requires reporting, blocking and removal of abusive users for apps with user-generated content.

Sources

  • Cloud Firestore documentation and data modelling — Google Firebase · firebase.google.com/docs/firestore
  • Firebase Security Rules guide — Google Firebase · firebase.google.com/docs/rules
  • Firebase pricing — Google Firebase · firebase.google.com/pricing
  • React Native Firebase documentation — Invertase · rnfirebase.io
  • App Store Review Guidelines, section 1.2 User-Generated Content — Apple · developer.apple.com/app-store/review/guidelines
  • Age appropriate design: a code of practice for online services — Information Commissioner's Office · ico.org.uk

Related reading

More from the Time2Launch blog.

Show More

Tell us about your project!

Your request will be my top priority once it reaches my inbox. I will make sure that the best team that fits your task will contact you as quickly as possible.

Oleg Romanov

Oleg Romanov

Founder at Time2Launch

Email

hq@time2launch.uk

Call

+44 7496 000 511

See Our Work