https://github.com/jrop/react-router-spa-demo
A single page application that can also render on the server using React.js
https://github.com/jrop/react-router-spa-demo
Last synced: about 1 year ago
JSON representation
A single page application that can also render on the server using React.js
- Host: GitHub
- URL: https://github.com/jrop/react-router-spa-demo
- Owner: jrop
- Created: 2015-07-08T20:32:25.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2017-09-01T17:24:43.000Z (almost 9 years ago)
- Last Synced: 2025-06-10T16:04:10.184Z (about 1 year ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
react-router-spa-demo
=====================
This is a very simple project that can render the requested page on the server-side, and then leave any other rendering to the client (using React + react-router). It reuses as much code as possible (i.e., the React Components to construct the views).
Building
========
To build the project, first make sure you have webpack installed:
```
npm i -g webpack
```
Then you may build:
```
npm install
#
# now go in an re-install react-router
# to use the latest version (1.0.0-beta3)
#
cd node_modules/
rm -rf react-router/
git clone https://github.com/rackt/react-router.git
cd react-router/
npm install
#
# Get back to root directory and build
#
cd ../..
webpack
#
# Run the server
#
node main.js
```
Basic Structure
===============
Here is a basic structure of the source files:
* `assets/` - The source files that webpack reads in
* the entry file is: `assets/js/app.js`
* all of the files in this folder except `app.js`, and `client-routes.js` can run on both the client (browser) and the server (node)
* `controllers/` - The controllers for handling HTTP requests
* `views/default.vash` - The basic HTML5 template used by express.js
* `controller.js` - The base-controller
* `main.js` - The main server entry-point; this file proxies `server.js`, loading the babel.js hook first
* `server.js` - The file that sets up express.js middleware/routes, etc.