alexlobera / universal-create-react-app

43 stars 23 forks source link

Universal Create React App

This project is a refactoring of the default app created by create-react-app v1.0.7, and then ejected.

A universal app runs both on the server and the client, and shares as much code as possible between the server and client - typically around 90%.

Development

Production

For a step by step explanation read the article https://medium.com/leanjs/universal-create-react-app-step-by-step-b80ba68d125d

How to run this project

Explanation

The source code (src) is split in 3 folders:

The server is implemented using Express

There are two build scripts. One to build the JavaScript bundle that will be sent to the client. By default from the same server but you could serve it via a CDN or anywhere else. The other build script builds the JavaScript bundle that runs on the server.

The start script will try to run the client (Webpack Dev Server) on a given port (3000 by default). If the port is not available it will try to find another port. We have implemented the same on the port used to run the server. The start script will try to run the server (Express compiled with Webpack) on a given port (5678 by default). If the port is not available it will try to find another port.

For a step by step explanation read the article https://medium.com/leanjs/universal-create-react-app-step-by-step-b80ba68d125d

Features

All the features that you have in create-react-app are included in this project, plus react-router v4.

Acknowledgments

Apollo GitHunt-React example was a great source of inspiration for finding solutions.

README generated by create-react-app v1.0.7

You can read here the original README.md generated by create-react-app in this repo https://github.com/facebookincubator/create-react-app/blob/v1.0.7/packages/react-scripts/template/README.md