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.

Prakash Prajapati Prakash Prajapati I’m a Senior Python Developer specializing in building secure, scalable, and highly available systems. I work primarily with Python, Django, FastAPI, Docker, PostgreSQL, and modern AI tooling such as PydanticAI, focusing on clean architecture, strong design principles, and reliable DevOps practices. I enjoy solving complex engineering problems and designing systems that are maintainable, resilient, and built to scale. Caio Rodrigues Caio Rodrigues I'm a full-stack developer focused on building practical and scalable web applications. My main experience is with **React, TypeScript, and modern frontend architectures**, where I prioritize clean code, component reusability, and maintainable project structures. I have strong experience working with **dynamic forms, state management (Redux / React Hook Form), and complex data-driven interfaces**. I enjoy solving real-world problems by turning ideas into reliable software that companies can actually use in their daily operations. Beyond coding, I care about **software quality and architecture**, following best practices for componentization, code organization, and performance optimization. I'm also comfortable working across the stack when needed, integrating APIs, handling business logic, and helping transform prototypes into production-ready systems. My goal is always to deliver solutions that are **simple, efficient, and genuinely useful for the people using them.** Franck Plazanet Franck Plazanet I am a Strategic Engineering Leader with over 8 years of experience building high-availability enterprise systems and scaling high-performing technical teams. My focus is on bridging the gap between complex technology and business growth. Core Expertise: 🚀 Leadership: Managing and coaching teams of 15+ engineers, fostering a culture of accountability and continuous improvement. 🏗️ Architecture: Enterprise Core Systems, Multi-system Integration (ERP/API/ETL), and Core Database Structure. ☁️ Cloud & Scale: AWS Expert; architected systems handling 10B+ monthly requests and managing 100k+ SKUs. 📈 Business Impact: Aligning tech strategy with P&L goals to drive $70k+ in monthly recurring revenue. I thrive on "out-of-the-box" thinking to solve complex technical bottlenecks and am always looking for ways to use automation to improve business productivity. Nam Tran Nam Tran 10 years as fullstack developer BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. Sage Fulcher Sage Fulcher Hey I'm Sage! Im a Boston area software engineer who grew up in South Florida. Ive worked at a ton of cool places like a telehealth kidney care startup that took part in a billion dollar merger (Cricket health/Interwell health), a boutique design agency where I got to work on a ton of exciting startups including a photography education app, a collegiate Esports league and more (Philosophie), a data analytics as a service startup in Cambridge (MA) as well as at Phillips and MIT Lincoln Lab where I designed and developed novel network security visualizations and analytics. I've been writing code and furiously devoted to using computers to make people’s lives easier for about 17 years. My degree is in making computers make pretty lights and sounds. Outside of work I love hip hop, the Celtics, professional wrestling, magic the gathering, photography, drumming, and guitars (both making and playing them) Yovel Cohen Yovel Cohen I got a lot of experience in building Long-horizon AI Agents in production, Backend apps that scale to millions of users and frontend knowledge as well. Kingsley Omage Kingsley Omage Fullstack software engineer passionate about AI Agents, blockchain, LLMs. Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture

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