Nextjs 14 Server Action to update reactive data from Mongo Change Stream
Unanswered
West African Lion posted this in #help-forum
West African LionOP
Hi,
We are using Next.js 14.0.4 with App router. Do you know the correct way to update a reactive data for a component (the UI needs 'use client') from a database (we are using MongoDB Change Streams)?
I'm new to React and Next and I'm not sure if I just need a Server Action to update a data variable to pass as props to the Client Component.
We would like to use zustand as state managment in the browser, so maybe it's better to use socket.io, Server Side Events (SSE), or maybe another solution?
Thanks!
We are using Next.js 14.0.4 with App router. Do you know the correct way to update a reactive data for a component (the UI needs 'use client') from a database (we are using MongoDB Change Streams)?
I'm new to React and Next and I'm not sure if I just need a Server Action to update a data variable to pass as props to the Client Component.
We would like to use zustand as state managment in the browser, so maybe it's better to use socket.io, Server Side Events (SSE), or maybe another solution?
Thanks!
5 Replies
Hey man I think this video will help you alot:
https://www.youtube.com/watch?v=VBlSe8tvg4U
https://www.youtube.com/watch?v=VBlSe8tvg4U
@Noronha Hey man I think this video will help you alot:
https://www.youtube.com/watch?v=VBlSe8tvg4U
West African LionOP
Hi, I saw this video yesterday! But in the docs from "revalidatePath" it is written that "revalidatePath only invalidates the cache when the included path is next visited". Is it needed to refresh the entire page then? Thanks!
@West African Lion Hi, I saw this video yesterday! But in the docs from "revalidatePath" it is written that "revalidatePath only invalidates the cache when the included path is next visited". Is it needed to refresh the entire page then? Thanks!
if you use
revalidatePath with server action on the page, it will show updated data without refreshyeap, it's like magic.
West African LionOP
Thanks!!