I have some doubts on overall architecture of complex, data driven UIs. Taking the usual blog page example with a sidebar, header and logo where the idea is that:
In the real world, when I build this it would rather be like:
In the end, everything on my page is subject to some sort of user interaction or user induced state. I cannot imagine a UI I have built over the last few years that simply loads static content in an isolated manner.
The only thing that occurs to me is that for SEO I may load some data driven HTML as a skeleton via server side component so that SE Bots can read the data immediately, and then display with the interactive client side equivalent once it's ready. Not sure if that's possible using <Suspense />
I may have to do a little reading.
Otherwise, with the above use case, am I missing something? I simply can't think of a real life use case for server side components except for data fetching because every single item on my page will always be subject to user interaction (hence: user interface).
Thanks for any clarifications :)
There is a great article about this in the NextJs app router documentation.
TLDR: You are right. In a blog based system like the one you are describing, most of the use case for server components is data fetching.
Personally, the system we have built has large dependencies and data fetching tokens that we keep on the server side of things. This significantly reduces load times for the client, and improves security. It also in some cases has allowed us to bypass writing a REST api in favor of directly querying our data.
It doesn't seem like simple state management for toggling a sidebar would even really benefit from server side. It does not present a large dependency problem, or private tokens/etc that would preferably be kept private. As I said earlier, I agree with you on the analysis that your use case would not benefit greatly from SSR components.
That being said, there is a lot of potential in parallel routes. This would allow you to toggle layouts, logos, or other content at the same URL using solely SSR components. If you structured your app correctly, only the 'controller/toggler' components would need to be client, and the rest could be SSR. (It is unclear if this would really provide much of a performance advantage, unless you pre-rendered all of the SSR statically and used the cache)
I am sure you are aware of this, but you also have the option of rendering SSR components as children of CSR components, which would allow you to more dynamically choose how to structure your project.