How do I use react syntax without using 'use-client' #50722
Replies: 3 comments 3 replies
-
|
the way you can do that is to start thinking about server rendering by default, in your navbar the Link(s) will bear query parameters that will be used by the next http call to rebuild the state of the navbar you an see an example here, in my case I just need the projectId, you might need something more complex |
Beta Was this translation helpful? Give feedback.
-
|
'use client' doesn't make code client side rendered! (Suspense does that) In the pages directory everything was actually "use client", so using "use client" is like using pages directory for SSR rendering, don't worry about SEO |
Beta Was this translation helpful? Give feedback.
-
Client components are pre-rendered as part of the SSR pass. That is a feature of Next.js, other frameworks might act differently. I'd say, either turn off JS, or inspect the "view-source" of your page. If the HTML is not there, it might be suspended by an upper boundary. For what is worth, if I remember correctly, for SEO, there should not be any suspending: https://nextjs.org/docs/app/building-your-application/routing/loading-ui-and-streaming#example Could you expand a bit further? Your component is not being visible in the initial HTML payload, right? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I'm trying to make dynamic multi-level dropdown navbar. On using react hooks it gives an error : "You're importing a component that needs useRef. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default."
I fixed this using
'use client'but on making its client component the browser will not be able to read the full source page. I need the whole source page for SEO.How do I fix this? Any suggestion
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions