Skip to content

josephDev123/you-might-not-need-websocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ You Might Not Need WebSockets – Build a Real-Time Chat with Server-Sent Events (SSE)

This project shows how to build a real-time chat app without WebSockets using Server-Sent Events (SSE) β€” a native, simpler alternative for pushing server updates to the client.

βœ… No socket errors
βœ… No reconnection logic
βœ… Native HTTP-based stream


❓ What Problem Does This Solve?

Most real-time apps default to WebSockets, but that often introduces:

  • Extra libraries on both frontend and backend
  • Persistent connections and resource management
  • Reconnection edge cases and complexity
  • Infrastructure scaling challenges

This project solves that by using Server-Sent Events (SSE) to stream updates from server to client with less overhead and no third-party dependencies β€” ideal when only the server needs to push updates (e.g., chat, notifications, live logs).


πŸš€ Features

  • Real-time message updates using SSE
  • Lightweight and works over HTTP/1.1
  • Pure JavaScript (no socket libraries)
  • Express backend + React frontend

🧠 How It Works

  • Client sends a message to the server
  • Server processes and resolves it to all connected clients via SSE
  • Clients receive updates in real-time through an EventSource stream

πŸ“¦ Getting Started

  1. Start the backend (Express + SSE stream endpoint)
  2. Start the frontend (React + EventSource)
  3. Type a message β€” it instantly appears for all connected users

🀯 Why Not WebSockets?

WebSockets are great, but not always necessary. For one-way, real-time updates from server to client, SSE is simpler and more efficient. No need for complex connection handling β€” just plug and stream.


πŸ‘¨β€πŸ’» Author

Built by Joseph Uzuegbu

πŸ“œ License

MIT – free to use, modify, and share.

About

Real-time data between client and server without websocket

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published