Stream Live Crypto Prices With Server-Sent Events
This lesson uses Server-Sent Events (SSE) to push live crypto price updates from a NestJS backend into a Next.js dashboard, keeping charts current without a single page reload.
Why SSE Fits Here
SSE opens a one-way, persistent connection from server to client and trickles small messages down it over time. Because crypto prices move quickly and you never need to send data back over that same channel, SSE is a lighter-weight fit than round-tripping requests for every tick.
Building the Backend
- Create a controller route that returns an Observable, where each emitted value becomes one SSE message
- Pull new prices from an API or stream inside a service, then emit them to the controller for delivery
Building the Frontend
On the Next.js side, the browser's EventSource API listens to the SSE endpoint and fires on every new message, so the page can parse each update and refresh the chart with very little client code.