Server or Client?

I've previously used client components too much, I'm developing an app and once I deployed it to Vercel it was pretty sluggish, I went out of my way to ensure the layouts and most pages were Server components, but now i'm regretting this. Is it bad practice to make all the pages client components so I can show a loder while they're loading?
9 Replies
deforestor
deforestor11mo ago
Imo that's a good idea Making everything server-side has a lot of down side
Y7YA
Y7YA11mo ago
You don't need to make the pages client sided to show a loader, suspense & loading.tsx is what you're probably looking for.
tsx
tsxOP11mo ago
My inital page load is a few seconds, especially if I leave it for an hour or so and then try to load
Y7YA
Y7YA11mo ago
Probably due to await blocks You need to strategically use suspense to load the part of the UI which is awaiting data, meanwhilst the rest of the ui which doesn't should load quickly - not causing the entire page to wait for that data.
deforestor
deforestor11mo ago
But why not have the page client-side? It's fine to load the page first if most of your components load on the server
tsx
tsxOP11mo ago
Wait, if I have a client layout the components it imports that are server side will be loaded server side?
deforestor
deforestor11mo ago
Damn I forgot about that, I think not. Haven't used the app route enough yet
Y7YA
Y7YA11mo ago
yes you can put server components in client components and they will be rendered on server side
tsx
tsxOP11mo ago
thx
Want results from more Discord servers?
Add your server