Web development went from server rendered applications to single page applications rendered fully on the client, and then it all got complicated. N...
For further actions, you may consider blocking this person and/or reporting abuse
great post! 👏
I wonder in a point "Can I Pass Props from a Client Component to a Server Component?", could we say we can pass through URL?
I mean, we do something like this
Thanks :)
router.refresh() should work I suppose, since it do refresh Server Components.
Although, I wouldn't recommend it. I would probably rather turn the Server Component into a Client Component and read the URL with useRouter (or pass as prop if they are not needed to be persisted in the URL).
The reason? Because that way, it all is handled automatically. Manually having to refresh the page when URL is changed is error-prone, one day that will likely turn into a bug.
Plus, if you would need to fully refresh your Server Component to get the URL params to it, you are probably better of with a Client Component, performance-wise.
Great article. I’ll love if permitted to add a little correction: client components are rendered in the server too, but hydrated in the client. This is a great article to understand: article
Yes, that's a great addition, for a full page reload. Not sure if I have written something which implies the opposite somewhere, but either way, it's a great point that should have been brought up as a question in this article.
Thanks for your comment. I did not understood what you meant by “for a full page reload”.
I added my comment based on your text here:
There’s a lot of confusion about the server-client rendering of next.js, that’s why I added the comment.
Lot of people think it’s bad to render client components as next.js was built for server rendering but that’s far away from the reality as you pointed out several times in your article.
Thanks for reading! Let me know if I should post more articles like this by writing a comment or reacting with some of the reactions ❤️🦄 🔥
Woah, loved the post. So much Next.js, haha!
You can also check out this, I'm not sure if it's helpful but it's related to Nextjs.
12 things you didn't know you could do with Nextjs
Anmol Baranwal ・ Feb 20
useRouter should be imported from next/navigation.
Thanks for pointing out. I updated it. My import was from old page components :)
Written well
Yup, that clears a lot of stuff 🎯. RSC are hard to understand initially considering they are a different mental model.