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.

Bastien Labelle Bastien Labelle Full stack dev w/ 20+ years of experience 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. Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems 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. Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : ) zipking zipking I am a technologist and product builder dedicated to creating high-impact solutions at the intersection of AI and specialized markets. Currently, I am focused on PropScan (EstateGuard), an AI-driven SaaS platform tailored for the Japanese real estate industry, and exploring the potential of Archify. As an INFJ-T, I approach development with a "systems-thinking" mindset—balancing technical precision with a deep understanding of user needs. I particularly enjoy the challenge of architecting Vertical AI SaaS and optimizing Small Language Models (SLMs) to solve specific, real-world business problems. Whether I'm in a CTO-level leadership role or hands-on with the code, I thrive on building tools that turn complex data into actionable value. Stanislav Prigodich Stanislav Prigodich 15+ years building iOS and web apps at startups and enterprise companies. I want to use that experience to help builders ship real products - when something breaks, I'm here to fix it. 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.**

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