← Back to context

Comment by user34283

3 days ago

I used to think the same about server-side rendering until I more closely looked at React SSR.

I think it makes a lot of sense and allows for faster initial rendering of the page while automatically setting up the JS and interactivity in the background.

Couldn't you just static render the parts that you're using SSR for?

I am not trying to be dismissive, but a common strict requirement is static hosting from a CDN, embedded environments, etc.

  • If you static render, it won't be an interactive application.

    With React SSR you get the best of both: stream static HTML chunks immediately, and rehydrate with JS later, prioritizing components the user interacts with.

    It should load quicker compared to traditional React apps where the browser loads the HTML, then loads the JS bundle, and only then renders a loading skeleton while likely triggering more requests for data.

    • > It should load quicker compared to traditional React apps where the browser loads the HTML, then loads the JS bundle, and only then renders a loading skeleton while likely triggering more requests for data.

      Then your JS bundle is broken.

      Promises exist. Modules exist. HTTP/2+ exists. You can load data while you are loading a small amount of JS required to render that data while you are loading other parts of your JS.

      If everything is sequential: load giant JS bundle -> fetch -> render, that's because someone architected it like that. Browsers give you all the tools you need to load in parallel, if you don't use them then it's not the browser's fault.

      You do not need SSR or rehydration. That's just Vercel propaganda. They saw that people are doing a stupid thing and decided to push a complex solution to it. Why? It makes them money.

      2 replies →

    • Static rendering has nothing to do with interactivity in a web app.

      I guess if you're already so deeply entrenched in writing all your application logic on the server side you need React SSR, but that sounds miserable.

    • You seem to be confused about your terms, both SSR and SSG can rehydrate and become interactive, you only need SSR if you have personalized content that must be fetched on an actual user request, and with frameworks like astro introducing island concept it even let's you mix SSG and SSR content on a single page.

      2 replies →

React has always supported server-side rendering and there have been many tools over the years to "rehydrate" data from the server to the client for when the client-side React application "takes over".