5

In an article I read that

React uses server-side rendering.

But in another articles I came across this:

Client-Side-Rendering is a relatively new approach to rendering websites, and it didn't really become popular until JavaScript libraries started incorporating it into their style of development. Some notable examples are Vue.js and React.js

Now Which statement is correct?

When I use create-react-app and run npm start, it seems to me that React uses the Client-Side-Rendering. isn't it?

user1941537
  • 6,097
  • 14
  • 52
  • 99
  • 2
    Yes, you're right in that CRA uses client-side rendering. React can also be server rendered. E.g. [Razzle](https://github.com/jaredpalmer/razzle) uses both server-side rendering and client-side rendering. – Tholle Mar 16 '19 at 19:21
  • Making statements from unverified sources without even linking them doesn't make sense. You clearly took quotes out of context. *Does React use server-side-rendering or client-side-rendering?* - both. – Estus Flask Mar 16 '19 at 19:25
  • 3
    @estus nobody is trying to misrepresent anything on purpose. It's a legitimate question. – M - Mar 16 '19 at 19:38
  • @Marquizzo I'm not accusing nobody. Yet the question could be asked in more constructive way. In this form it's prone to speculations. I'm positive an article didn't really state that React uses only server-side rendering. – Estus Flask Mar 16 '19 at 19:52
  • Does this answer your question? [ReactJS server-side rendering vs client-side rendering](https://stackoverflow.com/questions/27290354/reactjs-server-side-rendering-vs-client-side-rendering) – Josh Correia Jun 01 '21 at 18:24

4 Answers4

6

It’s client side. But React, like some other client side libraries, can be used on the server to prerender it with node, usually for SEO.

jorbuedo
  • 2,041
  • 1
  • 8
  • 20
  • 1
    Thanks. But what happens on a server like Heroku or Netlify? Are they using a node server or similar technic to render the react app on the server? – user1941537 Mar 16 '19 at 19:30
  • 1
    @user1941537 You can set up a server-rendered React app on Heroku, which will run in Node.js like you say. Netlify is more geared toward static assets, so you either just serve a SPA that is client-side rendered or a pre-rendered app with e.g. [Gatsby](https://www.gatsbyjs.org/). – Tholle Mar 16 '19 at 19:42
4

Out of the box it renders on the client side.

But, if you have a requirement to render pages on a server, you can achieve this with:

Next.js or Hypernova or any other tool (there is a bunch of them nowadays!)

Note, that SSR will require a bit more experience than a regular React app.

The main goal of this approach is to allow search engine robots crawl information form web pages(SEO).

Mark Rogers
  • 96,497
  • 18
  • 85
  • 138
flppv
  • 4,111
  • 5
  • 35
  • 54
1

create-react-app uses client side rendering by default. There are some tools like next js and gatsby js which pre-render pages on the server side. You can also do Server Side Rendering from scratch.

Muljayan
  • 3,588
  • 10
  • 30
  • 54
1

A few years on from the last answer, it is now quite difficult to implement a client-only React app - serving it on Node is trivial and absolutely what it expects, trying to use it as a client library with other server-side support is more of a challenge and documentation about how to do this is patchy and much of it out of date.

glenatron
  • 11,018
  • 13
  • 64
  • 112