About using the ‘use client’ directive in Mui
Unanswered
Weevil parasitoid posted this in #help-forum
Weevil parasitoidOP
I’m having this issue with using Mui and Next14 using app router. Could you give me some advice on this issue? I appreciate it very much
19 Replies
@Weevil parasitoid I’m having this issue with using Mui and Next14 using app router. Could you give me some advice on this issue? I appreciate it very much
Client components are SEO friendly because they are prerendered on the server normally
For example, the entire pages router is 100% client components
So no need to stress about client components
Weevil parasitoidOP
- So when using ‘use client’, the Google bot can also read data from the server.
- So how is using ‘use client’ different from not using it.
- Can you suggest some pages on this topic for me
- So how is using ‘use client’ different from not using it.
- Can you suggest some pages on this topic for me
@Weevil parasitoid - So when using ‘use client’, the Google bot can also read data from the server.
- So how is using ‘use client’ different from not using it.
- Can you suggest some pages on this topic for me
* yes
* to the browser, server components are just static html, while client components are normal interactive React components
* https://github.com/reactwg/server-components/discussions/4
* to the browser, server components are just static html, while client components are normal interactive React components
* https://github.com/reactwg/server-components/discussions/4
@joulev * yes
* to the browser, server components are just static html, while client components are normal interactive React components
* https://github.com/reactwg/server-components/discussions/4
Weevil parasitoidOP
- I read in the Next.js documentation that it says ‘By defining the ‘use client’ directive in toggle.js, you can tell React to render the component and its children on the client, where the APIs are available.’
- Can you explain this to me?
- I may have misunderstood https://nextjs.org/docs/app/building-your-application/rendering/client-components
- Can you explain this to me?
- I may have misunderstood https://nextjs.org/docs/app/building-your-application/rendering/client-components
@Weevil parasitoid - I read in the Next.js documentation that it says ‘By defining the ‘use client’ directive in toggle.js, you can tell React to render the component and its children on the client, where the APIs are available.’
- Can you explain this to me?
- I may have misunderstood https://nextjs.org/docs/app/building-your-application/rendering/client-components
React does render them on the client. But React also renders an initial version of the component on the server. Read the link I sent
@joulev React does render them on the client. But React also renders an initial version of the component on the server. Read the link I sent
Weevil parasitoidOP
Thank you very much for helping me. Maybe I should go read the articles you sent here
It’s by a (former?) core member of the React team and a frequent contributor to Next.js. It’s very informative. Just read it.
Masai Lion
@joulev can Nextjs fetch data for client component while SSRing it on server? How to achieve that? currently i have put fetch code in component with useSWR but it shows loading state instead of actual data..
Masai Lion
i found your comment https://discord.com/channels/752553802359505017/752647196419031042/1073158352730869831
so the fallback data should be sent from RSC.. but in that scenario any subsequent navigation from client would also make a hit to server.. is there any way to avoid it? any subsequent navigation from client should happen only on client...
so the fallback data should be sent from RSC.. but in that scenario any subsequent navigation from client would also make a hit to server.. is there any way to avoid it? any subsequent navigation from client should happen only on client...
no. you must choose either SSR or not SSR. can't have in between.
technically you can have shallow routing e.g. https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#windowhistorypushstate but will need lots of testing to get things working, besides it won't look nice
@joulev no. you must choose either SSR or not SSR. can't have in between.
Masai Lion
from what i read, it was available with page router? First load from server rendered and rest on client
@Masai Lion from what i read, it was available with page router? First load from server rendered and rest on client
i guess you are referring to getInitialProps? getServerSideProps doesn't allow you to do that
anyway, it's not possible with the app router and i'd say it's an intentional design decision. the app router is already complex enough as it is
Masai Lion
so now one has to pay for server cost - even though there is not much of a use case for making subsequent rendering from server
and everyone is adopting it? i am still scratching my head
and everyone is adopting it? i am still scratching my head
well im not paid to advertise you nextjs. you know the features and the limitations. you make the decision whether to use it or not.
from nextjs popularity, it seems not everyone is having a rest backend endpoint for the frontend to fetch() whenever the route is changed.
from nextjs popularity, it seems not everyone is having a rest backend endpoint for the frontend to fetch() whenever the route is changed.
Masai Lion
Grateful for your responses, did not meant to offend you.
But i am bewildered at the popularity of the project which does not support a very common use case with BFF architecture
But i am bewildered at the popularity of the project which does not support a very common use case with BFF architecture