# Build a Chat Application in Lovable

- Tool: Lovable Prompts
- Last updated: June 2026

## TL;DR

Paste the starter prompt into Lovable Build mode and get a real-time peer messaging app: one-on-one and group conversations, message history, typing indicators, and per-participant RLS using Supabase Realtime postgres_changes. Full build takes about 1 day and ~100–160 credits. lovable-realtime does not exist — this kit uses the real Supabase Realtime API.

## Frequently asked questions

### Is lovable-realtime a real import I can use?

No. lovable-realtime does not exist as an npm package or Lovable API. It is a hallucination that appears in several competitor prompt guides — if you try to import it, you get a module-not-found error immediately. The real feature is Supabase Realtime, which is part of the @supabase/supabase-js client you already have. The correct pattern is: supabase.channel('your-channel-name').on('postgres_changes', {event: 'INSERT', schema: 'public', table: 'messages', filter: 'conversation_id=eq.' + id}, handler).subscribe(). That is what this kit uses.

### How many concurrent users can this handle on the Free tier?

Supabase Free tier caps Realtime at 200 concurrent connections. This is not 200 total users — it is 200 users with the app open and connected simultaneously. In practice, if 10% of your daily active users are online at the same time, you can support ~2,000 DAU before hitting the cap. Supabase Pro ($25/mo) raises the cap to 500 concurrent connections. Past 500, you need to migrate to Pusher Channels (starting at $49/mo for 100 connections) or Ably. Plan this migration before launch if chat is the core feature.

### Can I do end-to-end encryption (E2EE) in Lovable?

Not with this starter prompt — messages are stored in plaintext in your Postgres database and are visible to anyone with the service-role key (including Lovable Cloud's infrastructure). True E2EE requires encrypting messages client-side with the recipient's public key before sending, and decrypting client-side after receiving — the database sees only ciphertext. This is technically possible with the Web Crypto API in the browser, but it is complex to implement correctly and is out of scope for a Lovable Build mode session. If E2EE is a hard requirement (HIPAA, legal communications), you should use a purpose-built E2EE messaging service (Matrix/Element, Signal Protocol library) rather than building from scratch in Lovable.

### How do I send push notifications to mobile users?

Supabase Realtime only works when the browser tab is open. For background notifications when the app is not open, you have two options. First, the Resend email notification flow in follow-up #4 handles users who have been inactive for 5+ minutes. Second, for true mobile push notifications, you need Web Push API (for progressive web apps) or integrate with Expo Push Notifications if you wrap the app in React Native. The Web Push setup requires a service worker and VAPID key — prompt Lovable with 'Add Web Push notifications to the chat app using the Web Push API and a service worker, with VAPID keys stored in Cloud Secrets.'

### What's the cheapest way to scale past 500 concurrent users?

The most practical path is: (1) stay on Supabase Realtime up to ~500 concurrent connections with Supabase Pro ($25/mo); (2) when you approach 400 connections, add Pusher Channels (Starter plan $49/mo for 500K messages/day, unlimited connections). The migration in your codebase is swapping useRealtimeMessages from the Supabase channel pattern to pusher-js, and adding an Edge Function that publishes to Pusher on message INSERT. Ably is a similar alternative starting at $25/mo.

### How do I prevent spam or abuse without manual moderation?

Add a message rate limiter as a Postgres BEFORE INSERT trigger: count messages per user in the last 10 seconds and RAISE EXCEPTION if count > 10. This is described in the production checklist. For content moderation, add an OpenAI Moderation API call in a BEFORE INSERT trigger — if the message body is flagged, set is_deleted = true immediately and send a moderation notification to the conversation admin. Without at least rate limiting, a public or semi-public chat will become a spam vector within hours of launch.

### Can I embed this chat inside another app I am building in Lovable?

Yes — the chat is built as standard React components and Supabase tables, so you can add it to any other Lovable project. The steps are: (1) copy the SQL migration to the other project and run it; (2) copy the component files; (3) add a /chat route to your other app's router. The only integration point is auth — both apps must use the same Supabase project (same auth.uid() values) for the participant lookups to work. If you have two separate Lovable projects with separate databases, you cannot share chat participants across them without a manual migration.

### Can RapidDev build this chat application for me end-to-end?

If your build outgrows this prompt kit and you need custom architecture, RapidDev builds production-grade Lovable apps at $13K-$25K — book a free 30-minute consultation at rapidevelopers.com.

---

Source: https://www.rapidevelopers.com/lovable-prompts/lovable-prompts-for-building-chat-application
© RapidDev — https://www.rapidevelopers.com/lovable-prompts/lovable-prompts-for-building-chat-application
