Your One-Stop solution for a full-stack app with ES6/ES2015 React.js featuring universal Redux, React Router, React Router Redux Hot reloading, CSS modules, Express 4.x, and multiple ORMs.
https://react-webpack-node.herokuapp.com/
-
isomorphicuniversal Rendering -
Redux Predictive state containers.
-
Server-side rendering with React Router 2.x. Having server-side rendering allows you to pre-render the initial state of your components when a user (or search engine crawler) requests a page.
-
Integrating Redux with React Router with
Redux Simple RouterReact Router Redux -
Asynchronous Data Fetching on server-side rendering
-
Server side authentication + Redirecting for components
-
Hot reloading using react-transform-hmr
-
Time travel using Redux-Devtools Chrome Extension
-
Webpack for both development and production bundles. It's (in my opinion) the best bundler for JS, CSS, LESS, images, and lots more!
-
CSS Modules allows for modular and reusable CSS. Say goodbye to conflicts (most of them) and global scope
-
Unit Tests with webpack, karma, jsdom, mocha, & sinon
- Reducers
- Components
- Synchronous and Asynchronous Actions
-
Express 4.x server with a ton of middleware
-
Mongoose for MongoDB
-
Sequelize for Postgres
-
Procfile to enable deployment to Heroku & Docs on Salt configurations + Deployment for Digital Ocean
The motivation is simple, best practices. Everyone's ultimate goal is to build a non-trivial applications. Performant and free of bugs, we want our applications to be secure and joy for the user. We believe that using a mixture of with React.js and Webpack and Node is the best way to accomplish this. (hence...react-webpack-node).
This boilerplate serves a second purpose as well. It is a learning tool for any and all that are interested in learning how to put a large React application together. We have had extensive additions to this boilerplate from the community over time as practices have evolved, and we are always interested in hearing new ideas and welcome all forms of help.
I'm really a fan of this implementation of flux for state management. The main principles of having:
- a single store
- state being read-only (you have to express an intent to mutate being creating actions)
- mutations written as pure functions
make it very fun and easy to write predictable code! There's a ton of reasons why, but you should head to the Redux docs to dive in!
Or if you are more of a visual learner watch the free egghead video series narrated by the creator of redux:
A simplistic representation of data flow from server to client is:
Express app.use() receives a request
-> Calls a pre-built webpack file for the server
-> Runs matching of routes in react-router for server
-> Makes async data fetching request
-> Renders Route component to string
-> Construct HTML file (with Meta, Link tags using helmet)
-> Browser receives html file with initial state
-> Client side React.JS kicks in and initializes with given state
-> Continues where it left off
-> Everyone is happy :)
More TBD
You will have to install redux devtools extension from here and then everything should just work!
We currently support MongoDB and Postgres, as well as the ability to not use any database. Learn about how to configure your app.
Development is a breeze. Once you have installed all your dependencies all the configuration is done for you. using simple The process is outlined here.
Testing with:
karma
as test runnerkarma.conf.js
for the main karma configuration (it has webpack configurations)tests.webpack.js
which is the single entry file. It useswebpack
's require API to find all the files we need that have a-test.js
suffix.
mocha
as the test frameworkjsdom
as my test environment
# Run test once
npm test
# Run in watch mode
npm test:watch
We have unit tests for async (redux) actions, reducers, and components.
Currently we support Heroku and Digital Ocean and AWS
If you like using yeoman generators, you could check out this cool yeoman generator by @iiegor!
We have assembled an FAQ here
We have a list of projects that have been created with this boilerplate. Check them out to see what can be done or to get some inspiration.
Best way to keep up to date is check the issues. I really welcome improvements for all aspects of an app.
- Any suggestions/improvements/bugs can be in the form of Pull Requests, or creating an issue.
- Coding guidelines:
Credits to webpack-server-side-example, example-app, flux-examples, node-express-mongo-demo, hackathon-starter, web-starter-kit, awesome material-ui, alt and iso, react-starter, reap, isomorphic-redux-app and mxstbr/react-boilerplate
Easter Eggs 🥚
This boilerplate has gone through an evolution
React.js -> Facebook Flux -> Alt -> Redux
We have two implementations of universal flux:
- Redux is on our active master branch
- Alt (previously implemented) on flux/alt branch. It features iso, react-router and ImmutableJS.
Note: If you have previously used an alt implementation of this repository, please refer to this branch. I will not be updating it as frequently as master, but definitely welcome suggestions!
MIT