Test project for server side rendering React within Django using GraalVM polyglot programming.
Based on the GraalVM Java + Python polyglot example.
- The code quality is bad
- A lot of patching was needed
- It feels like it barely works
- Django runs on a single thread
- Django does not refresh on code changes
- I was unable to get GraalPy running and supporting JavaScript without running it via Java
- JAVA_PATH pointing at GraalVM JVM
- node
- npm
- maven
Run npm install
and npm build
in the react-ssr
folder.
Copy the resulting react-ssr/dist/client-bundle.js
to src/main/resources/vfs/proj/static/client-bundle.js
Run mvn package
Somehow apply the patch in patches/django/django.patch
. You can for example use patch
pip package.
Run mvn exec:exec
The React app should be SSR'd and hydrated when you open http://localhost:8000/?user=weee
patch -p1 < patches/django/django.patch
mvn package -Pnative