Next.js Discord

Discord Forum

Update data in realtime without websocket

Answered
Rebon posted this in #help-forum
Open in Discord
I have an app that is made up of 2 pages. Admin and user. The user is able to change his status from active to inactive. The admin has a list of all users and their status. The problem that I am facing is that I want is when the user changes his status the pages of the admin gets. updated without refreshing on blurring and focusing back on. I have tried tRPC and cache validation but it didn't work. How can I achieve the real time change?
Will using revalidateInterval cost a lot of money since they are run on the server?
Answered by B33fb0n3
you can also subscribe to specific database events. When you use aws amplify graphql, you can directly use these [realtime subscriptions](https://docs.amplify.aws/gen1/javascript/build-a-backend/graphqlapi/subscribe-data/). If you are using for example prisma, you can also subscribe to realtime events [see here](https://v1.prisma.io/docs/1.34/prisma-client/features/realtime-JAVASCRIPT-rsc8/#:~:text=The%20Prisma%20client%20lets%20you,the%20model%20(but%20lowercased).).
View full answer

7 Replies

the current tRPC in built on React query. But I am using db search queries function in the queryfn. Would that cost me function calls in hosting?
is there a way to only refetch automatic when the data is mutated, and update the ui without refreshing?
@Rebon is there a way to only refetch automatic when the data is mutated, and update the ui without refreshing?
you can also subscribe to specific database events. When you use aws amplify graphql, you can directly use these [realtime subscriptions](https://docs.amplify.aws/gen1/javascript/build-a-backend/graphqlapi/subscribe-data/). If you are using for example prisma, you can also subscribe to realtime events [see here](https://v1.prisma.io/docs/1.34/prisma-client/features/realtime-JAVASCRIPT-rsc8/#:~:text=The%20Prisma%20client%20lets%20you,the%20model%20(but%20lowercased).).
Answer
Okay, I will try to test that out. Thanks a lot ❤️❤️
@Rebon Okay, I will try to test that out. Thanks a lot ❤️❤️
Happy to help. Is your thread solved like that?