is refetching every second a bad idea?
I am creating an auction app,users fire mutation on click that writes current bid in db but in order to synchronize changes on every client I have set the query that gets that data on refetchinterval 1000,expected use case is about 50 users for around 1 hour,should I maybe do that some other way ?
10 Replies
you probably want websockets
^^
can you do that with trpc and deploy on vercel?
agreed
Are you sure you can do WS and deploy to vercel? Once you add sockets, you need a persistent server, I don't think their's a way to do that with NextJS?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Pusher is just a SaaS that lets you do realtime messaging via their API, pretty useful if you're trying to set up something like a chatroom
Is there a way to persist data using web sockets?
Let’s say I use usestate to set all clients data that one of them sends,for simplicity let’s say I have a button that simply adds 1 to the displayed number ,when someone refreshes they get the value use state initially set for them and if they press the button it goes to initial state +1
Not super sure what you mean by persisting data, but WS is event driven so if you wanted, every time a user clicked the button, you sent an event to the WS server saying button pressed or whatever and then you could tell the WS server to send an event to all the listeners or users on that event
You should define your requirements
Most importantly “when a bid is made, how long until everyone else sees that information”