When using react in real world projects is it rendered in server side?


#1

At the moment I can create react apps, get content from APIs and all that good stuff. Recently I say a tutorial where react is rendered through express:

const app = express();

app.use(express.static("public"));

app.get('*', (req,res)=>{
	res.send(`<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <script src="/bundle.js" defer></script>
</head>
<body>
  <div id="root">${renderToString(<App />)}</div>
</body>
</html>`);
})

Is this the approach professionals take or do they just create react apps (kind of starting with create-react-app) and just reaching for an API,

What I'm trying to figure out is, I am going to learn how this works just to say I played with it, but is this the approach I should use every time I create react apps?


#3

Every react project you encounter will be different since react imposes few architectural decisions on developers who use it. This is one of the selling points of react over the strict, rigid structural architecture of angular. If you are building a large application with react you will ultimately end up creating your own framework and everyones is going to be different.


#4

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.