All Projects β†’ moosh3 β†’ django-react

moosh3 / django-react

Licence: other
Server side rendering of react components integrated with django

Programming Languages

python
139335 projects - #7 most used programming language
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to django-react

resource-center
New version of the resource center built with ReactJS
Stars: ✭ 89 (+217.86%)
Mutual labels:  react-components
ancestor
πŸ’€ UI primitives for ReScript and React
Stars: ✭ 144 (+414.29%)
Mutual labels:  react-components
hx
A simple, easy to use library for React development in ClojureScript.
Stars: ✭ 244 (+771.43%)
Mutual labels:  react-components
klyva
A state management library that follows the React component model
Stars: ✭ 53 (+89.29%)
Mutual labels:  react-components
react-jwt-auth
React JWT Authentication & Authorization example - React.js Login and Registration example
Stars: ✭ 307 (+996.43%)
Mutual labels:  react-components
OpenTrivia
Multiplayer quiz game demo using React and Opentdb API
Stars: ✭ 47 (+67.86%)
Mutual labels:  react-components
best-of-react
πŸ† A ranked list of awesome React open-source libraries and tools. Updated weekly.
Stars: ✭ 364 (+1200%)
Mutual labels:  react-components
Nectus
A boilerplate Flask API for a Fullstack Project with some additional packages and configuration prebuilt. βš™
Stars: ✭ 32 (+14.29%)
Mutual labels:  react-components
vimana-framework
Vimana is an experimental security framework that aims to provide resources for auditing Python web applications.
Stars: ✭ 47 (+67.86%)
Mutual labels:  django-templates
git-issue-react-electronjs
βš™οΈ. βš›οΈ. A desktop application created with Electronjs and Reactjs to be cross-platform to manage and track GitHub issues.
Stars: ✭ 21 (-25%)
Mutual labels:  react-components
rebass
βš›οΈ React primitive UI components built with styled-system.
Stars: ✭ 7,844 (+27914.29%)
Mutual labels:  react-components
deer-ui
Deer UI δΈ€δΈͺε―ζ’ζ‹”οΌŒθ½»ι‡ηΊ§ηš„ React η»„δ»ΆεΊ“
Stars: ✭ 46 (+64.29%)
Mutual labels:  react-components
mint-ui
Design System | React UI components for web
Stars: ✭ 17 (-39.29%)
Mutual labels:  react-components
react-sanctum
Easily hook up your React app to Laravel Sanctum and Laravel Fortify
Stars: ✭ 100 (+257.14%)
Mutual labels:  react-components
tiny-ui
βš›οΈ A friendly UI component set for React.js
Stars: ✭ 202 (+621.43%)
Mutual labels:  react-components
Registration-and-Login-using-MERN-stack
Simple Registration and Login component with MERN stack
Stars: ✭ 210 (+650%)
Mutual labels:  react-components
react-lds
⚑ React components for the Salesforce Lightning Design System
Stars: ✭ 28 (+0%)
Mutual labels:  react-components
jsx-test
An easy way to test your React Components (`.jsx` files).
Stars: ✭ 27 (-3.57%)
Mutual labels:  react-components
react-simple-image
responsive img tag with cleaner srcset/sizes interface.
Stars: ✭ 29 (+3.57%)
Mutual labels:  react-components
orfium-ictinus
This repo will include the building blocks to create the Orfium Parthenons to come ...
Stars: ✭ 20 (-28.57%)
Mutual labels:  react-components

rendered-react-django

React is a MVC framework javascript library for building user interfaces. Although tempting, the use of react wrecks an apps SEO. The package react-python allows the rendering of react components to occur on the server side. Here's the github repository for django-react.

This project is an example of using react components using this package. It uses Material-UI to follow Google's material guidelines. It's pretty.

https://github.com/owais/django-webpack-loader

Dependencies

The purpose of python-react is to replace the django template system with react components. The package has multiple node dependencies, and requires a render server in order to render the components on the server-side. So, implementing this package would affect:

  • The way Django templates are used. A {% rendered raw %} tag would replace any HTML (React can render JSX into native HTML if we don't want to include any react components but want to stay consistent with the template style).

  • An extra proccess to render the components. Best to use Supervisor to run the render server in the background consistently. We can also wrap the call to the server to first check if the data is cached locally and populate the rendered markup with that data to ease the load.

Passing in data

python-react takes a dictionary of data that can be passed through the renderer for use on the client side, i.e.:

render_component(
    path='',

    props={
        'foo': 'bar'
    },
)

django-webpack-loader

The other direction to go in is using a module bundler like webpack. The package django-webpack-loader consumes bundles (i.e. React components) and generates static bundles that can then be used in Django templates. This writeup does a great job at explaining the relationship between webpack, react and django.

React.js also has a tutorial regarding the use of webpack to render bundles on the server side. This may be the preferred approach, as it allows:

  • frontend engineers and designers to run webpack mode in watch mode
  • use grunt, gulp, or any dev server without limitations
  • makes it easy to use npm or bower as a package manager

The limitations to this approach over something like python-react include:

  • decouples frontend django and backend, making it harder to store static files in app directories (although changing to this workflow is more awesome)
  • That's about all, folks

Modern frontends with Django along with Webpack plus hot react components are great starting points. The packages used for this approach include

How to Install

currently does not run correctly, migrating from python-react to django-webpack-loader

pip install requirements
cd react
npm install
node server.js
cd ..
manage.py runserver
{% load render_bundle from webpack_loader %}
<html>
  <head>
    <meta charset="UTF-8">
    <title>Django, Webpack and ReactJS</title>
    {% render_bundle 'main' 'css' %}
  </head>
  <body>
     <!-- Using django-webpack-loader -->
     {% render_bundle 'main' 'js' %}

     <!-- react-render options below -->
     {{ my_component }}
     <!-- .render_props outputs JSON serialized props.
     This allows you to reuse the encoded form of your props on the client-side.
     -->
      <script>
        var myProps = {{ my_component.render_props }};
      </script>
  </body>
</html>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].