I finished both next js courses from Mosh. I am currently building an app. And I realized when fetching data, I have two methods. I can either stay in the server side (how mosh did with prisma), or I can go into the CSR, and use React Query and an API call to get the data. I am just not sure when to use which method.
You’re asking when to use Client-side Rendering (CSR) and when to use Server-side Rendering (SSR).
According to my limited knowledge (I’m a mobile dev basically), SSR is great for SEO (Search Engine Optimisation), while CSR might is a good choice if you want to give an app-like view to the user.
You can read about both ways online and then decide which suits your case best. There is no silver bullet in software development, and sometimes we find ourselves changing our approach drastically after v1. So, it’s okay to think about these matters, but don’t spend extra time figuring out the “best” way for your case.
Yeah this is pretty accurate, if you want a rule of thumb if the data is static, SSR. If it’s dynamic on page CSR. Or use SSR as much as possible if content may be searchable (text). You can see this by using inspector tool, ssr text displays before render, csr does not and search engines crawlers don’t render fully usually.
What’s nice about next is you can select individual components to be either ssr or csr on the same page to mix and match.