Good day, I write SPA using React and Django, who made friends with each other using webpack-django-loader and Django REST Framework - Django transfers data via API and processed java-script file with the following code:

async componentDidMount() { try { const res = await fetch('http://127.0.0.1:8000/api/main'); const MainPage = await res.json(); this.setState({MainPage}) } catch (e) { console.log(e); } } 

Naturally, data rendering takes place on the client side. The question is how to organize server rendering React + Django and what are the approaches as well as best practices?

  • Best practice will be an isomorphic application on react + node js. The node will go api to django backing. It will be possible to render the same reagent shalbony on the server. If it doesn’t fit, then render it on the server using jinja for example, and then connect the reactor, you get a little duplication of templates, but this is the output if you don’t want to use node js - abakan
  • You can separately launch Django server for api and separately Express for reak application. This course explains everything well. Udemy.com/server-side-rendering-with-react-and-redux - Ivan Semochkin

0