# Realtime Features with WebSockets

> Push live updates such as notifications, chat and status changes using WebSockets, Server-Sent Events or a managed service. Free notes, key concepts, resources...

Canonical: https://www.internhack.in/roadmaps/tracks/full-stack/realtime
Last updated: 2026-11-28

Push live updates such as notifications, chat and status changes using WebSockets, Server-Sent Events or a managed service.

Advanced · about 5 hours · difficulty 4/5

Learn first: [Sessions, Cookies and JWTs](https://www.internhack.in/roadmaps/tracks/full-stack/sessions-vs-jwt), [Node.js Runtime Essentials](https://www.internhack.in/roadmaps/tracks/full-stack/nodejs-runtime)

Some features need the server to push data: "your application was shortlisted", a live interview chat, or a contest leaderboard.

### Options

- **Polling**: the client asks every few seconds. Simple and often good enough.
- **Server-Sent Events (SSE)**: one-way server-to-client stream over HTTP. Great for notifications and progress updates.
- **WebSockets**: full two-way connection. Needed for chat, collaborative editing and games. **Socket.IO** adds rooms, reconnection and fallbacks.
- **Managed services** (Pusher, Ably, Supabase Realtime) work well with serverless hosting where you cannot hold connections.

### Design concerns

- **Authentication** on connect, and authorization for each room or channel.
- **Scaling**: with multiple server instances, use a pub/sub layer like Redis so a message reaches users connected to any instance.
- **Reconnection** and missed messages: store events in the database and let clients catch up.

### Pitfalls

- Using WebSockets when polling every 30 seconds would do.
- Trying to hold WebSocket connections inside serverless functions.
- Broadcasting private data to a room without checking membership.

You are ready to move on when your portal shows live application status updates to students, authenticated per user, and still works after a page refresh or reconnect.

## Key concepts

- **Polling vs SSE vs WebSockets**
- **Socket.IO rooms and events**
- **Authenticating connections**
- **Scaling with Redis pub/sub**
- **Reconnection and catch-up**
- **Managed realtime services**

## Mini project

Build a live notifications feature: when a recruiter changes an application status, the student sees a toast instantly via SSE or Socket.IO, with missed notifications loaded from the database on reconnect.

## Check yourself

You scale your WebSocket server to two instances and some users stop receiving messages. Why, and what fixes it?

## Free resources

- [The WebSocket API](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) (MDN)
- [Socket.IO Documentation](https://socket.io/docs/v4/) (Socket.IO)
- [Using server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) (MDN)

Previous: [File Uploads and Object Storage](https://www.internhack.in/roadmaps/tracks/full-stack/file-uploads) · Next: [Background Jobs, Queues and Scheduled Tasks](https://www.internhack.in/roadmaps/tracks/full-stack/background-jobs)

## More in Beyond CRUD: Real-World Features

- [File Uploads and Object Storage](https://www.internhack.in/roadmaps/tracks/full-stack/file-uploads)
- [Realtime Features with WebSockets](https://www.internhack.in/roadmaps/tracks/full-stack/realtime)
- [Background Jobs, Queues and Scheduled Tasks](https://www.internhack.in/roadmaps/tracks/full-stack/background-jobs)
- [Payments with Razorpay](https://www.internhack.in/roadmaps/tracks/full-stack/payments-razorpay)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Full-Stack Developer Roadmap](https://www.internhack.in/roadmaps/tracks/full-stack)
