#Suggestion for using server vs client component

19 messages · Page 1 of 1 (latest)

gilded locust
#

Hi, I'm quite new to SSR and I'm wondering which approach is better and why? It's just a simple example to help me understand it better I basically just have a edit button on a page and when I click it I want to show the editor for the page.

  1. Wrap the entire page in a client component, then use state and when you click button set state so component is re-rendered with the editor instead of content.

  2. Keep the page server rendered and redirect the user to page/?editing=true and then check for params when rendering the component if editing param is passed then render editor instead of the page.

So basically my question is if it's better to do redirects and keep things on the server or does it make more sense to use client side components and state?

stark boltBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

neon shadow
#

That’s a good question, im curious to know the answer too.

gilded locust
#

Any particular reason why that's better?
I basically change the entire page when you click the button so it also makes sense to me to render the whole page again on the server with a redirect but might not be the most elegant.

coarse bane
gilded locust
#

So that's basically approach 1 right by using state and client side components

#

or am I not understanding it?

coarse bane
gilded locust
#

Hmm I'm not understanding what you mean then

#

so what happens when you click the edit button?

coarse bane
gilded locust
#

but that would require client side component right to use state?

gilded locust
#

yeah so approach 1 then to render the editor when state changes when you click the button

coarse bane
gilded locust
#

Hmm alright

coarse bane
gilded locust
#

Thanks! will give it a read