Crash Course: Server-Sent Events (SSE) with Express.js & EventSource

Опубликовано: 10 Март 2025
на канале: Coding With Adam
3,920
125

In this tutorial, we will dive into the world of Server-Sent Events (SSE) with a hands-on approach. I will guide you through setting up an Express.js server to handle SSE events and creating a simple HTML and JavaScript frontend to manage SSE event streams using EventSource.

🔍 What You'll Learn:
Setting up an Express.js server for SSE
Handling SSE event streams with EventSource in JavaScript
Building a basic client-side implementation with HTML and JS

📚 Resources & Links:
Code
https://github.com/CodingWith-Adam/ss...
MDN Event Source
https://developer.mozilla.org/en-US/d...

If you enjoy this tutorial please subscribe, like and share

Chapters
00:00 Intro
00:16 HTTP vs SSE
01:15 Project Setup
02:44 Express.js Setup
03:27 SSE Endpoint
03:46 SSE Endpoint Headers
05:33 SSE Endpoint Send Example Data
06:42 SSE Endpoint Send Current Time
7:57 Client Setup
09:34 EventSource onMessage
11:18 EventSource addEventListener
11:59 SSE How to add Events Server Side
13:31 SSE EventSource Client Side addEventListener for Color