SSR with NextJS's App Router #61982
Replies: 4 comments 2 replies
-
|
Both
Long story short, by adding |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the reply. From the snippet in React Docs, I thought Client Components (marked through 'use client' directive) are rendered on the client only.
Basis your link to NextJS, NextJS renders client components also on the server which is what I am looking for. I will now go on the journey of marking the boundaries properly with use-client directive to achieve SSR. |
Beta Was this translation helpful? Give feedback.
-
|
If I use "use client" directive, the server doesnt render the HTML at all. The payload has only Javascript and its the browser which does everthing. |
Beta Was this translation helpful? Give feedback.
-
|
let's say you need to fetch a list of posts, and you use i guess the list of posts will be fetch in the browser side, and the google spider will not be able to see the list correct ? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I already have React Client Components coded with lots of useState and useRef. If I use Pages Router architecture of NextJS, I am able to render this on the server side (SSR) perfectly. But I want to use the new App Router architecture as thats the latest direction of NextJS company. But App Router architecture uses React Server Components by default (RSC) and RSC has lot of restrictions around the usages of useState and useRef for good reasons. But it defeats the purpose of using the existing code to get SSR using NextJS. I dont want to mark those as "use client" as I want them to be server rendered for SEO purposes.
In my particular case, fetching data from server is a simple thing and thus RSC is not solving a lot for me there. But the HTML is interactive a lot and thus useState and useRef are used heavily.
I am wondering whether I am wrong in my understanding of latest App Router architecture where it forces RSC and thus the existing code has to be rewritten properly to make them Server Side Rendered? Or there is a way I can get SSR working on the old client components without changing them a lot and hydration enables interactivity on those components on the browser side.
Beta Was this translation helpful? Give feedback.
All reactions