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
Imo that's a good idea
Making everything server-side has a lot of down side
You don't need to make the pages client sided to show a loader,
suspense
& loading.tsx
is what you're probably looking for.My inital page load is a few seconds, especially if I leave it for an hour or so and then try to load
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.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
Wait, if I have a client layout the components it imports that are server side will be loaded server side?
Damn I forgot about that, I think not. Haven't used the app route enough yet
yes you can put server components in client components
and they will be rendered on server side
thx