What I've already done
- I have a frontend entirely built with React.JS.
- All the business logic is handled by Django and exposed by Django REST Framework via an API.
- I'm able to build for different mobile environnements (Android and iOS via Cordova)
- The web application is accessible via my Django project (the same that exposes the api), the frontend is sill the same ReactJS code bundled via webpack.
The App has a single entry point, main.js which is a bundled version of my react.js components and dependencies, so my index.html typically looks like this :
<body> <script type="text/javascript" src="/static/bundles/main-3997ad3476694c3c91cf.js"></script> </body>
What I want to do
- I want to provide a server-side rendering of my web application to let web crawlers correctly index my app on web (I'm not looking for server-side rendering for mobile builds)
How can I handle this considering the fact that my app is a Single Page Application ? I do not want to reinvent the wheel nor to duplicate my code. What kind of node.js server do I have to write in order to achieve this automatic server-side rendering ? Is there any way to provide the server side rendering directly in Django (via some tools reading and interpreting the final results of the page as displayed on the client-side and returning this raw html ?)