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
├── .env
└── .gitignore
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 react_pages # development
$ react-pages deploy # production
$ react-pages runserver # django runserver alternative
Django Integration
settings.py
INSTALLED_APPS = [
...
'react_pages',
...
]
# React Pages
REACT_PAGES_PROJECT_DIR = os.path.join(BASE_DIR, 'my_project') # specify the react-pages project
STATICFILES_DIRS = [
...
os.path.join(REACT_PAGES_PROJECT_DIR, 'build') # mark the build dir as static file dir
...
]
template.html
{% load react_pages %}
...
{% render_react_page 'vote' %}
...
Remeber to use react-pages runserver
instead of manage.py runserver
!
That's it! React Pages will pick-up the "vote" page from "poll_react_pages" project and do the necessary work to transpire react JSX.
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.
Existing projects
React Pages will automatically patch itsef into any existing project,
that was created using create-react-app
.
Just run react-pages project .
from your project directory!
Projects not using create-react-app
will probably work, but no guarantees can be made.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file react-pages-0.0.9.tar.gz
.
File metadata
- Download URL: react-pages-0.0.9.tar.gz
- Upload date:
- Size: 168.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec02d14476178ad375e496bae1048eabec4348b82c939d8f929b9ceee1c62e90 |
|
MD5 | 476b54ae7c629e6d990e3ae483b9b542 |
|
BLAKE2b-256 | 11b6e7cf5fcd36953f783b115b18694b90b6660602e8c9bd968b40d5779c15c8 |
File details
Details for the file react_pages-0.0.9-py2.py3-none-any.whl
.
File metadata
- Download URL: react_pages-0.0.9-py2.py3-none-any.whl
- Upload date:
- Size: 912.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3603e93a0c30ace4b539cf0ec9c492f0392eb70da789cf94f810c1f906612704 |
|
MD5 | fd83303155d601647af87a20d5a8a826 |
|
BLAKE2b-256 | 79d3117843d98e625ebc7cddc5ef0e8e6e688a5643fca9525f6a3365d0301b6c |