My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Eric Burel

31 likes

·

1.1K reads

3 comments

Rijk van Wel
Rijk van Wel
Feb 12, 2024

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.

·
·2 replies
Eric Burel
Eric Burel
Author
·Feb 12, 2024

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

·
Rijk van Wel
Rijk van Wel
Feb 12, 2024

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.

·