Difference between server/client components? When to use?

I kind of just wanted to know when some good practices are when it came to using server/client components. First time using Next and I sometimes see people creating like a seperate api directory or something like that. If there's any resources you know that are helpful that would be awesome
6 Replies
Neto
Neto17mo ago
server components are meant to create "pure html" elements with no state nor anything client related (like useState, useEffect)
BigBellyBigDreams
BigBellyBigDreamsOP17mo ago
@nyx (Rustular DevRel) ohhh so its like logical components basically
Neto
Neto17mo ago
Astro Documentation
Astro Islands
Astro Islands (aka Component Islands) are a pattern of web architecture pioneered by Astro. “Islands architecture” was first coined by Etsy's frontend architect Katie Sylor-Miller in 2019, and expanded on by Preact creator Jason Miller.
Neto
Neto17mo ago
look this astro doc no js -> (kinda) server component js -> client component
BigBellyBigDreams
BigBellyBigDreamsOP17mo ago
makes sense, so on my client components it should be pure html and all my state handling / logic is contained in the server component and in that case server components are not "rendered" right or are they?
Neto
Neto17mo ago
server components are meant to give you "pure html" that is the point of the await and suspense
Want results from more Discord servers?
Add your server