6

So I've been looking around for a solution to render React JS components on my server. I use flask and have found a few pieces of software that help with this (https://github.com/markfinger/python-react and https://github.com/defrex/django-react) and I don't really like the idea of having a separate Node process for the render server.

So I was wondering if I could use something like Pyv8, PyReact, and aysincio to render it server side and have my front end application isomorphic.

If worse comes to worse I'll use the server render but I feel like it adds a layer of complexity (even though it's not too horrible of a solution) that doesn't really need to be added.

4
  • afaik react is client side not server side .... so im not sure what your asking ... but yes you can do python client side though libraries like skulpt... usually python is the backend and the react would be part of a template that flask or django or whatever is rendering ... Commented Sep 23, 2015 at 14:38
  • Videos likes this: youtube.com/watch?v=8wfY4TGtMUo cover why you would render the react components server side. Most of these server side rendering solutions are done with node though. Commented Sep 23, 2015 at 14:50
  • Please see How to use jinja2 server side rendering alongside react without violating inline-script CSP with respect to using React with Jinja templates in Flask. Also, to @JoranBeasley point, you still need something on the server side (API, etc) if you want to make component state dependent on an external data source. Commented Sep 23, 2015 at 15:19
  • 1
    @RobertHickok Hi, Did you find a solution to this? Commented Apr 27, 2016 at 6:59

1 Answer 1

3

I've been working on python-react-v8, I think it's what you want, it will render react views server side, there are some examples included.

It's built on top of v8-cffi, which embeds V8 into Python, so there is no separate process running.

Also, it is in the same vein as react-rails and react-php-v8js. There was something similiar to this made by facebook, but they deprecated it, hopefully now you can use python-react-v8 instead.

Sign up to request clarification or add additional context in comments.

1 Comment

python-react-v8 is buggy. It can't process some functions so I can't find any use to it. v8cffi.exceptions.V8JSError: webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:5260 var localClearTimeout = clearTimeout; ^ ReferenceError: clearTimeout is not defined

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.