Skip to main content

Keep Connection (keepConnectionOnUnmount)

By default, <Chatbot> aborts the in-flight SSE connection when it unmounts. Setting keepConnectionOnUnmount to true lets an in-flight round finish on the backend when the component unmounts because the user navigated to another in-app page; the connection auto-closes once the run completes (or after a safety timeout).

Note: this only covers in-app unmounts. A full page reload, tab close, or network loss still tears the connection down, since the page itself is gone.

Connection Settings

Behavior

On unmount, the in-flight SSE run is kept alive so the round can finish on the backend (the connection auto-closes once the run completes).

How to verify

  1. Mount the chatbot and send a message that produces a long streaming reply.
  2. While it is still streaming, click "Unmount chatbot".
  3. Watch the message/sse request in the DevTools Network panel: with the flag on the request runs to completion; with it off it is cancelled on unmount.
Loading chatbot...

Code Example

<Chatbot
keepConnectionOnUnmount
config={{ botProviderEndpoint: "..." }}
customChannelId="your-channel-id"
{...rest}
/>

Further Reading