Summary
In this chapter, you learned about real-time technologies and techniques and how to use them in Remix.
First, we discussed polling, SSE, and the WebSocket API and compared their advantages and disadvantages. Polling is the easiest to set up. A simple polling implementation does not require changes on the server. SSE provides a one-way communication line using the HTTP protocol, while WebSocket connections use TCP and are bi-directional.
Second, you learned about server requirements for SSE and WebSocket. You now understand that SSE requires support for streaming responses, while WebSocket servers can only run on long-running servers.
Finally, we implemented a real-time UI in BeeRich by utilizing SEE. We implemented a new endpoint and associated React hook using the EventSource
API. Since Remix’s loader
functions return HTTP Response
objects, we can implement the server-sent event endpoint in Remix using a resource route.
In the next chapter, we will learn...