Skip to content

itsgood87/fastify-sse-example

Repository files navigation

Fastify Server-Side Events Example

This project demonstrates how to set up a Fastify server that sends server-side events (SSE) to clients. Unlike websockets, this is a one-way connection. Data can only be sent from the server to clients.

There are two endpoints:

  • GET /: Navigate here to connect to the server using the EventSource API. The page displays connection status, the number of connected clients, an updating chart showing the data sent from the server, and a list of recent data points.
  • GET /sse: Hit this endpoint to establish a long-term connection and receive events. The server generates random-ish data and sends it to clients once per second.

This project uses Parcel to bundle the front-end code, LiquidJS for templating, Tailwind CSS for styling, and plain old javascript.

There's a fly.toml file and a Dockerfile used for deployment on Fly.

About

An example app using Fastify to send server-side events to clients.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors