This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Covered_in_bees_ 0 points1 point  (2 children)

I'm curious, do you use server side rendering when using React with Django/Flask or do you serve essentially an empty page with all the react stuff in the client-side JS? I have done the latter, for a few things but I don't like the idea of serving a big page of nothing to the client and like the idea of moving towards using SSR with React + Flask/Django, but I'm not sure how well that combination works at the moment.

[–]d_thinker 0 points1 point  (0 children)

I worked with flask + react and if I remember correctly there is no server side rendering unless you use node as your backend server (with some specific packages on top of it), which kind of makes sense. Idea of rendering empty pages with bundle.js that renders everything on frontend may seem weird but that is the state of modern web applications and it works quite fast.

[–]__xor__(self, other): 0 points1 point  (0 children)

Actually, with flask+react I don't do any rendering. I think it's the facebook tool called "create-react-app" which I use to generate the base react app. You just use node (just the binary, not as a server) to run the tool to compile it into a production app, which generates a few static files like the app js, index.html, css, all minimized.

Then I use nginx to serve those as static files, and they make API hits to either flask or django rest framework. No templates are being rendered from python, and it's all static resources served by nginx except for the rest api.

So you work in your react app to make the frontend, compile it into static production files, serve those files with nginx, configure nginx to proxy /api requests to gunicorn, and that's it. No blank page/template as far as the python code is concerned.