I don't understand how NextJS CSR and SSR works?
Answered
Cuckoo wasp posted this in #help-forum
Cuckoo waspOP
From what I understood if I declare a component as 'use client' the components imported in it except will not render on server side. I turned off JS on my browser, but the page still loaded like it used to load earlier. I want to understand how exactly it works. Is there any resources where I could learn this?
Answered by Ray
client component will be rendered on server
https://nextjs.org/docs/app/building-your-application/rendering/client-components#how-are-client-components-rendered
https://nextjs.org/docs/app/building-your-application/rendering/client-components#how-are-client-components-rendered
2 Replies
@Cuckoo wasp From what I understood if I declare a component as 'use client' the components imported in it except will not render on server side. I turned off JS on my browser, but the page still loaded like it used to load earlier. I want to understand how exactly it works. Is there any resources where I could learn this?
client component will be rendered on server
https://nextjs.org/docs/app/building-your-application/rendering/client-components#how-are-client-components-rendered
https://nextjs.org/docs/app/building-your-application/rendering/client-components#how-are-client-components-rendered
Answer
if you want to skip rendering on server, you could use
https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#skipping-ssr
dynamic with ssr disablehttps://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#skipping-ssr