real time data with subscriptions
Unanswered
Spectacled Caiman posted this in #help-forum
Spectacled CaimanOP
Hey guys what is the nextjs way to handle real time data updates with subscriptions in a pubsub way? I was considering Apollo Graphql subscriptions but it seems nextjs doesnt handle websockets so Im a bit new to this and Im a bit confused can someone please help me out here 😅
5 Replies
Australian Freshwater Crocodile
I would look into socketio, https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events, or long polling
SSE is probably the best option, but it really does depend on what you want to do.
@Australian Freshwater Crocodile I would look into socketio, https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events, or long polling
Spectacled CaimanOP
So I have this application where multiple clients join and have the same session together so they should all be able to subscribe to these events and when they cause a mutation in the database it should trigger the event for all clients listening to it ( in other words all clients in the same session) and call a function to all the listeners
basically I need an Eventmanager that clients can subscribe to and the server can emit events from. what is the nextjs way to handle this usually?
Btw a bit of background about my situation I am currently using apollo graphql for queries and mutations so using it for subscriptions seemed the logical way to do it but it seems like a pain to setup as I would have to have a separate server running because nextjs doesnt handle websocket connections? I'm confused sorry 😅