31 likes
·
1.1K reads
3 comments
I don’t get it.. why not make this a server component? There is no need for client data fetching. You can just call ‘refresh’ (or ‘revalidateTag’ from a server action) to reload the component.
Refresh will empty the server-side cache, but will not reload your component client side. Take a look at DataRevalidator from Tim Neutkens "Deep Dive" post, it shows another similar way to get fresh data client-side after a server revalidation, when the page is focused (in this article, I use polling instead so it gets data every X seconds): github.com/vercel/next.js/discussions/54075
Well yes, in the post you link Tim says exactly the same. He just sets up a "refresher" function that calls router.refresh()
in an interval/timeout/on focus. There is no data loading from the client. Calling refresh will reload your component if the data changed server side (make sure you disable/invalidate cache). Alternatively, you could set up a server action that calls e.g. revalidateTag("preorder")
; this will both revalidate the server cache and send the updated data in one roundtrip.