React (and Vue, et al) was built with client side rendering in mind. It just does not seem to fit the server side rendering pattern.

What are the use cases? From my perspective, if your app is a rich web app with a lot of interactivity, you probably want CSR and don’t benefit much from SSR.

If you have a content-centric site, or a site with some interactivity but not much, you want a static site generator, or SSR. But in that case, a template engine with some smaller client side libraries (jQuery or AlpineJS or idk what all is out there).

Using React SSR for all of these seems like the wrong tool. What am I missing?

  • Cyclohexane@lemmy.mlOP
    link
    fedilink
    arrow-up
    7
    ·
    10 months ago

    I agree that things improved. React and others are amazing for CSR. We have static site generators which are also amazing and nice to work with. But SSR territory is in strange place right now. React is overused in places it doesn’t belong.

    • fidodo@lemm.ee
      link
      fedilink
      arrow-up
      6
      ·
      10 months ago

      I’ve had a good time with react SSR and SSG particularly when using next.js which does a great job optimizing out of the box, but really SSR and SSG are functionally just glorified string interpolators so anything will do. What matters is ease of use and with the strong community and toolset available to react I’ve had no trouble setting up react for SSR/SSG.

      Where things still need improvement is with hybrid apps that take SSR/SSG pages and hydrate them to be ready for the client to take over, but that’s always been a pain point, and while we’re still not where we need to be I do think it’s better than it’s ever been and we’re on the right track to cracking it.

      Maybe it’s because I’ve seen how bad things can get that I’m appreciative of what we have. After experiencing frameworkless jQuery spaghetti code, overly complicated monoliths like angular, and overly simplified micro frameworks like backbone, I’m really happy with the frameworks and toolsets we have now, and react’s ecosystem is very mature.

      I would say that react is overkill for SSR, but pure SSR is pretty simple so react is also able to handle it just fine and elegantly as react is even easier to use when you’re not dealing with dynamic state, and if you find the need to introduce some hybrid client side functionally, which pretty much always happens eventually, it’s a good thing to be on react.

      • LufyCZ@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        10 months ago

        Nextjs is pretty far with the hybrid approach with appdir. It’s not perfect by any stretch of the imagination, but it works surprisingly well

    • tmRgwnM9b87eJUPq@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      10 months ago

      You can configure nextjs to compile as only client-side-rendering, so that it runs like before!

      Another thing: NextJS is not only SSR. It’s hybrid. The advantage here is that it decreases the visible first load time.

      First load pre-rendered HTML and styling is sent to the browser. So the page is already fully visible. After that all scripts and secondary CSS will be loaded. And even after that the bindings will be done.

      Where as with pure CSR, all JavaScripts need to be loaded and executed and only then stuff will become visible to the user