Skip to main content

A zero-fuss way to create non single page apps with react.

Project description

React Pages

A zero-fuss solution for using React for non-SPAs, django and other non-node environments.
  • Zero Configuration required.
  • Go from development to production with ease.
  • Automatically install node using nvm.
  • Natively use react in django/flask.

Terminology

Project

The project contains the node.js modules necessary to use react, some other js files, required by react pages itself and the pages you add.

└── project
    ├── package.json
    └── package-lock.json

Page:

A page is a directory containing at least an index.js file, (and probably other css/js files specific to your application.)

└── page
    ├── App.css
    ├── App.js
    ├── App.test.js
    ├── index.css
    ├── index.js
    ├── logo.svg
    └── registerServiceWorker.js

QuickStart

$ react-pages project poll_react_pages # create a project

$ cd poll_react_pages

$ react-pages page vote # create a page

$ react-pages develop # development

$ react-pages deploy # production

Django Integration

settings.py

INSTALLED_APPS = [
    ...
    'react_pages_django',
    ...
]

# Assuming your React Pages project is at BASE_DIR,
REACT_PAGES_PROJECT_DIR = os.path.join(BASE_DIR, 'poll_react_pages')

template.html

{% load react_pages %}
...
{% render_react_page 'vote' %}
...

That's it! React Pages will pick-up the "vote" page from "poll_react_pages" project and do the nessecary work to transpile react code.

Django Context

You can pass django template context varialbes like so -

views.py context['foo'] = [1, 2, 3]

template.html {% render_react_page 'vote' foo=foo %}

Then access these anywhere in react code console.log(foo);

Note: These must be JSON serialize-able

For production, just put DEBUG=False in settings.py and relax.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

react-pages-0.0.4.tar.gz (834.4 kB view details)

Uploaded Source

Built Distribution

react_pages-0.0.4-py2.py3-none-any.whl (6.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file react-pages-0.0.4.tar.gz.

File metadata

  • Download URL: react-pages-0.0.4.tar.gz
  • Upload date:
  • Size: 834.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for react-pages-0.0.4.tar.gz
Algorithm Hash digest
SHA256 7c0915cbb9257e66cbc14560db779db2f25ae28230edffec2ebdd6260061b5fd
MD5 1b8485c580fa21a6c7e7066b13d4b7c4
BLAKE2b-256 77a82de90d149ddad9270d6215776f0bacfbb0f64bd862b7ef84db2f55c80fd8

See more details on using hashes here.

File details

Details for the file react_pages-0.0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for react_pages-0.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8fc1d585d5bb08493bc3382204e1d009c5c999c5619ee1417b2346368b4dccaa
MD5 6ee73313ac0fdbf464421b68cf7d26b6
BLAKE2b-256 598b9302da8540831fb01bf7b5e2f95854f8b7c78fcfb6ac3d28774ff367e4a5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page