Skip to content

Latest commit

 

History

History

sse-chat

Server-Sent Events - Simple chat app

This example demonstrates how to use Server-Sent Events to create a simple chat app without persistant storage.

Preview

Open this example on CodeSandbox:

Open in CodeSandbox

Example

The example uses the eventStream response helper from Remix Utils to implement a SSE endpoint.

In that endpoint the server subscribe to an EventEmitter to get new messages and broadcast them to subscribers.

Client-side, the useEventSource hook from Remix Utils is used to subscribe to the SSE endpoint and display new messages as they arrive.

All paired with a Remix form to send new messages to an action which are then emitted to the EventEmitter.

Related Links