Bolt realtime

Chat Messages Not Updating in Real-Time in Bolt App

Your Bolt.new chat feature saves messages to the database correctly, but other participants don't see new messages until they manually refresh the page. The chat feels like an email inbox rather than a live conversation, making real-time communication impossible.

Users expect chat to be instant - messages should appear within milliseconds of being sent. When they have to refresh the page to see responses, they assume the feature is broken and will abandon it for a working alternative. This is a fundamental functionality issue that undermines the entire purpose of a chat feature.

The root cause is that Bolt generated a working CRUD interface for messages (create, read, update, delete) but didn't implement the real-time subscription layer that pushes new messages to connected clients as they arrive.

Error Messages You Might See

Realtime connection failed: WebSocket error Supabase Realtime: Table not enabled for replication Channel already joined Error: Maximum number of Realtime channels exceeded WebSocket connection to 'wss://...' failed
Realtime connection failed: WebSocket errorSupabase Realtime: Table not enabled for replicationChannel already joinedError: Maximum number of Realtime channels exceededWebSocket connection to 'wss://...' failed

Common Causes

  • No real-time subscription — Messages are fetched on page load but there's no WebSocket or Supabase Realtime subscription to receive new messages
  • Supabase Realtime not enabled — The Realtime feature is not turned on for the messages table in the Supabase dashboard
  • Subscription filter too broad or narrow — The Realtime subscription listens to the wrong table, wrong event type, or wrong filter condition
  • New messages not added to local state — The subscription receives events but the callback doesn't append the new message to the displayed list
  • Channel not subscribed — The channel is created but .subscribe() was never called, so no events are received
  • Cleanup function missing — Previous subscriptions aren't cleaned up on component unmount, causing duplicate messages or memory leaks

How to Fix It

  1. Enable Realtime on your table — In Supabase dashboard, go to Database > Replication and enable Realtime for your messages table
  2. Add a Realtime subscription — Subscribe to new messages: useEffect(() => { const channel = supabase.channel('messages').on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'messages', filter: `chat_id=eq.${chatId}` }, (payload) => { setMessages(prev => [...prev, payload.new]); }).subscribe(); return () => { supabase.removeChannel(channel); }; }, [chatId])
  3. Handle all event types — Subscribe to INSERT, UPDATE, and DELETE events to handle new messages, edits, and deletions
  4. Auto-scroll to new messages — After adding a new message to state, scroll the chat container to the bottom: messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' })
  5. Add optimistic updates — Show sent messages immediately in the UI before the database confirms, then reconcile when the Realtime event arrives
  6. Clean up subscriptions — Always remove channels in the useEffect cleanup function to prevent memory leaks and duplicate messages

Real developers can help you.

Milan Surelia Milan Surelia Milan Surelia is a Mobile App Developer with 5+ years of experience crafting scalable, cross-platform apps at 7Span and Meticha. At 7Span, he engineers feature-rich Flutter apps with smooth performance and modern UI. As the Co-Founder of Meticha, he builds open-source tools and developer-focused products that solve real-world problems. Expertise: 💡 Developing cross-platform apps using Flutter, Dart, and Jetpack Compose for Android, iOS, and Web. 🖋️ Sharing insights through technical writing, blogging, and open-source contributions. 🤝 Collaborating closely with designers, PMs, and developers to build seamless mobile experiences. Notable Achievements: 🎯 Revamped the Vepaar app into Vepaar Store & CRM with a 2x performance boost and smoother UX. 🚀 Launched Compose101 — a Jetpack Compose starter kit to speed up Android development. 🌟 Open source contributions on Github & StackOverflow for Flutter & Dart 🎖️ Worked on improving app performance and user experience with smart solutions. Milan is always happy to connect, work on new ideas, and explore the latest in technology. PawelPloszaj PawelPloszaj I'm fronted developer with 10+ years of experience with big projects. I have small backend background too Alvin Voo Alvin Voo I’ve watched the tech landscape evolve over the last decade—from the structured days of Java Server Pages to the current "wild west" of Agentic-driven development. While AI can "vibe" a frontend into existence, I specialize in the architecture that keeps it from collapsing. My expertise lies in the critical backend infrastructure: the parts that must be fast, secure, and scalable. I thrive on high-pressure environments, such as when I had only three weeks to architect and launch an Ethereum redemption system with minimal prior crypto knowledge, turning it into a major revenue stream. What I bring to your project: Forensic Debugging: I don't just "patch" bugs; I use tools like Datadog and Explain Analyzers to map out bottlenecks and resolve root causes—like significantly reducing memory usage by optimizing complex DB joins. Full-Stack Context: Deep experience in Node.js and React, ensuring backends play perfectly with mobile and web teams. Sanity in the Age of AI: I bridge the gap between "best practices" and modern speed, ensuring your project isn't just built fast, but built to last. Simon A. Simon A. I'm a backend developer building APIs, emulators, and interactive game systems. Professionally, I've developed Java/Spring reporting solutions, managed relational and NoSQL databases, and implemented CI/CD workflows. Kingsley Omage Kingsley Omage Fullstack software engineer passionate about AI Agents, blockchain, LLMs. prajwalfullstack prajwalfullstack Hi Im a full stack developer, a vibe coded MVP to Market ready product, I'm here to help Richard McSorley Richard McSorley Full-Stack Software Engineer with 8+ years building high-performance applications for enterprise clients. Shipped production systems at Walmart (4,000+ stores), Cigna (20M+ users), and Arkansas Blue Cross. 5 patents in retail/supply chain tech. Currently focused on AI integrations, automation tools, and TypeScript-first architectures. Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Nam Tran Nam Tran 10 years as fullstack developer

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

How do I enable Supabase Realtime for my messages table?

Go to Supabase dashboard > Database > Replication. Toggle on the messages table. Then in your code, subscribe to postgres_changes events on that table. Note that Realtime must be enabled per-table, it's not on by default.

Why do I see duplicate messages with Realtime?

This usually happens when the subscription callback adds the message but you also add it when sending. Either use optimistic updates (add on send, reconcile on subscription) or only add messages through the subscription callback. Also ensure you clean up subscriptions in useEffect cleanup to prevent duplicate listeners.

Related Bolt Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help