This repository contains a project template for React/NodeJS development
- Features
- Getting Started
- Application Structure
- Development
- Deployment
- Linting and Formatting
- History
Note: node 7.6 or later is required for this template to work since it uses ES6 generators
Setup directory for project:
git clone [email protected]:nwaywood/react-fullstack-template.git <your-project-name>
cd <your-project-name>
rm -rf .gitFrom the root directory, install the project dependencies and check that it works:
npm install # install dependencies
npm run serve # run the serverand then from another terminal:
npm start # compile and launch.
├── app # Frontend application
│ ├── public # Static resources (html, images etc)
│ └── src # Source code, which is bundled into the `dist` folder by `webpack`
│ ├── index.js # The entrypoint for the React application
│ ├── AppErrorBoundary.js # Generic top level Error Boundary for the application
│ ├── globalCSS.js # Any global CSS used in the application (should be kept to a minimum)
│ └── ... # Domain specific components
├── dist # Build directory, which is served by the server as static directory
└── server # Root folder for server code
Note: The structure of domain specific components within /src follow the presentational vs component model. Refer to this blog post for more information
npm startto start the development server. And to communicate with the api:
npm run serve:watchand the devServer will proxy api calls to the backend koa server... magic!
npm run build # compile project into /dist folderthen you can serve the production app with
npm run serveBy default the production server listens on port 3000
If you want to run the application on port other than 3000, simply define it as environment variable:
PORT=4000 npm run serveBuild the docker image:
docker build -t YOUR_IMAGE_NAME .
Run the container:
docker run -it -p 3000:3000 --name YOUR_CONTAINER_NAME YOUR_IMAGE_NAME
This project uses prettier integrated with eslint to show formatting errors via eslint. To automatically fix
these formatting errors you can run npm run format. However, it is recommended to integrate this functionality with
your editor to improve the development workflow.
For an overview of the evolution of this template and key design decisions we have made, see here