Clarification about client-routes
Unanswered
Korat posted this in #help-forum
KoratOP
import Contact from '@/app/components/Contact';
export default function ContactPage() {
return (
<Contact />
)
}
I am doing this, because the Contact component uses MUI and is a client component. I thought I should avoid making the route a "client", but do I have any benefit with this pattern or can I just render the content of "Contact" directly in the route and make the whole route a client route?
export default function ContactPage() {
return (
<Contact />
)
}
I am doing this, because the Contact component uses MUI and is a client component. I thought I should avoid making the route a "client", but do I have any benefit with this pattern or can I just render the content of "Contact" directly in the route and make the whole route a client route?
5 Replies
@Korat import Contact from '@/app/components/Contact';
export default function ContactPage() {
return (
<Contact />
)
}
I am doing this, because the Contact component uses MUI and is a client component. I thought I should avoid making the route a "client", but do I have any benefit with this pattern or can I just render the content of "Contact" directly in the route and make the whole route a client route?
Masai Lion
it is always better to do that even if you don't need "use client"
personaly i always do that to have a cleaner code
@Korat import Contact from '@/app/components/Contact';
export default function ContactPage() {
return (
<Contact />
)
}
I am doing this, because the Contact component uses MUI and is a client component. I thought I should avoid making the route a "client", but do I have any benefit with this pattern or can I just render the content of "Contact" directly in the route and make the whole route a client route?
do I have any benefit with this patternyes. if you put
use client to your page.tsx you say goodbye to export const metadata or export const runtime or similar stuffKoratOP
thank you both. @joulev yeahh, I remember reading something like that in the docs a few weeks ago, but I was not sure. do you know if mui components still get pre-rendered to a certain degree on the server-side? I have read about that, but it was not pretty clear to me. I thought they have optimized it.
@Korat thank you both. <@484037068239142956> yeahh, I remember reading something like that in the docs a few weeks ago, but I was not sure. do you know if mui components still get pre-rendered to a certain degree on the server-side? I have read about that, but it was not pretty clear to me. I thought they have optimized it.
client components are prerendered on the server (same as the pages router where all components are client components), so unless MUI uses something like
then it should be prerendered normally on the server too
const isMounted = useIsMounted();
if (!isMounted) return false;
return ...;then it should be prerendered normally on the server too