What if your app could magically update itself the moment something changes?
Why Subscriptions in NestJS? - Purpose & Use Cases
Imagine building a chat app where users want to see new messages instantly without refreshing the page.
You try to manually check the server every few seconds to get new messages.
Manually asking the server repeatedly wastes resources and slows down the app.
It also causes delays and can miss updates between checks.
This makes the app feel slow and clunky.
Subscriptions let the server push new data to the client instantly when something changes.
This means users see updates live without wasting resources on constant checks.
setInterval(() => fetch('/messages'), 3000);
const subscription = pubSub.asyncIterator('newMessage');Subscriptions enable real-time, efficient, and smooth data updates between server and client.
In a live sports app, fans get instant score updates as goals happen without refreshing.
Manual polling is slow and resource-heavy.
Subscriptions push updates instantly from server to client.
This creates fast, real-time user experiences.