From the course: HTMX Essential Training
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Handling server sent events - HTMX Tutorial
From the course: HTMX Essential Training
Handling server sent events
- [Instructor] Another thing that we can take advantage of with HTMX is the server sent event extension. So think about a server sent event as something where the server is sending events in a one-way pattern to our client. When we take a look at web sockets in a little bit, that's going to talk about how we have this bi-directional communication between the two. But server sent events are just going to take some data on the server and pass that to the client. So we need to make some adjustments to our server and our client to make this work. And we're going to get rid of a lot of this. So let's go ahead and get rid of in our server dot js file pretty much everything after the initial construction of our server. So this is going to just stand up our HTML page. We can get rid of everything in the style tag inside of the index dot html. And we'll get rid of pretty much everything inside of our body as well. The only thing we really want to keep is the H one. More to come there, but…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.