All Projects β†’ william-woodhead β†’ Simple Universal React Redux

william-woodhead / Simple Universal React Redux

Licence: mit
The simplest possible Async Universal React & Redux Boilerplate app, that works on both Mac and Windows

Programming Languages

javascript
184084 projects - #8 most used programming language
es6
455 projects

Projects that are alternatives of or similar to Simple Universal React Redux

Express React Boilerplate
πŸš€πŸš€πŸš€ This is a tool that helps programmers create Express & React projects easily base on react-cool-starter.
Stars: ✭ 32 (-44.83%)
Mutual labels:  eslint, babel, express, universal, react-router
Express Webpack React Redux Typescript Boilerplate
πŸŽ‰ A full-stack boilerplate that using express with webpack, react and typescirpt!
Stars: ✭ 156 (+168.97%)
Mutual labels:  eslint, babel, express, react-router, react-redux
React Redux Saucepan
A minimal and universal react redux starter project. With hot reloading, linting and server-side rendering
Stars: ✭ 86 (+48.28%)
Mutual labels:  eslint, babel, express, universal, react-router
React Social Network
Simple React Social Network
Stars: ✭ 409 (+605.17%)
Mutual labels:  async, redux-thunk, react-redux, react-router-v4
React Ssr Setup
React Starter Project with Webpack 4, Babel 7, TypeScript, CSS Modules, Server Side Rendering, i18n and some more niceties
Stars: ✭ 678 (+1068.97%)
Mutual labels:  eslint, babel, express, react-router
Js Stack Boilerplate
Final boilerplate code of the JavaScript Stack from Scratch tutorial –
Stars: ✭ 145 (+150%)
Mutual labels:  eslint, babel, express, react-router
Pwa
An opinionated progressive web app boilerplate
Stars: ✭ 353 (+508.62%)
Mutual labels:  eslint, babel, universal, react-router
React Redux Universal Boilerplate
An Universal ReactJS/Redux Boilerplate
Stars: ✭ 165 (+184.48%)
Mutual labels:  eslint, babel, sass, react-router
cerebro-web
Website for Cerebro
Stars: ✭ 21 (-63.79%)
Mutual labels:  babel, react-redux, redux-thunk, react-router-v4
Create React App Redux
React Router, Redux, Redux Thunk & Create React App boilerplate
Stars: ✭ 885 (+1425.86%)
Mutual labels:  redux-thunk, react-router, react-redux, react-router-v4
Budgeting
Budgeting - React + Redux + Webpack (tree shaking) Sample App
Stars: ✭ 971 (+1574.14%)
Mutual labels:  eslint, babel, sass, react-router
Xiaoduyu.com
🐟小度鱼 - εΉ΄θ½»δΊΊηš„δΊ€ζ΅η€ΎεŒΊ https://www.xiaoduyu.com
Stars: ✭ 549 (+846.55%)
Mutual labels:  babel, react-router, react-redux
Express Babel
Express starter kit with ES2017+ support, testing, linting, and code coverage
Stars: ✭ 621 (+970.69%)
Mutual labels:  eslint, babel, express
Push Starter
React Redux Starter with SSR πŸ€–
Stars: ✭ 43 (-25.86%)
Mutual labels:  express, universal, react-router-v4
React Redux Antdesign Webpack Starter
react + redux + ant design + react-router 4 + webpack 4 starter
Stars: ✭ 44 (-24.14%)
Mutual labels:  sass, react-router, react-router-v4
React Express Fullstack
Full stack (mostly unopinionated) starter pack with React+Redux and Expressjs
Stars: ✭ 23 (-60.34%)
Mutual labels:  eslint, babel, express
Diagonistician Reactjs Express Mongoose
Question - Answers demo SPA
Stars: ✭ 13 (-77.59%)
Mutual labels:  redux-thunk, express, react-router
Create React Redux App
This project was bootstrapped with Create React App and Redux, Sass Structure.
Stars: ✭ 46 (-20.69%)
Mutual labels:  async, sass, react-router
Js Stack From Scratch
πŸ› οΈβš‘ Step-by-step tutorial to build a modern JavaScript stack.
Stars: ✭ 18,814 (+32337.93%)
Mutual labels:  eslint, nodemon, react-router
Online Bling
Stars: ✭ 9 (-84.48%)
Mutual labels:  babel, express, sass

Simple Universal React Redux

The simplest possible Async Universal React & Redux boilerplate.

This repo is an attempt to make the simplest server-side rendered (universal) async React Redux app.

Boilerplates can be a great for two things:

  1. Get started with your application code quickly since you don't have to scaffold your app.
  2. Learn how apps can be scaffolded, and learn how technologies can fit together.

This repository is more aimed at the second point.

It was born out of frustrations with complex boilerplates where you can't understand what is going on behind the scenes. Developers tend to want to know how things work under the hood. This repo offers a boiled-down example to be tweaked and hacked around with.

It tries to be as un-opinionated and simple as possible.

It borrows heavily from the documentation of Redux and React-Router.

These are the technologies it uses:

For the app

Build tools

Commands

Install
yarn install
Develop
yarn run dev

Open localhost:3000

Build for production
yarn run build
Run in production
yarn run start

Open localhost:3000

Platform

This repo is developed and tested on Mac OS with node v10.10.0 and npm v6.7.0

Windows

This repo is tested on Windows. You might have to install nodemon globally though.

npm i -g nodemon

Documentation

Server side

Everything starts with the Express App. You can find this in src/server/index.js

Here we can see that all requests are routed to the handleRender function:

app.use(handleRender);

The handleRender function does a number of things:

  1. Create a new redux store on every request from the client
  2. Match the request path (req.path) to the react router routes specified in src/universal/routes
  3. Asynchronously fetch the data required to render this route (using the route's loadData function)
  4. Use react-dom/server renderToString function to create the required html
  5. Insert the html and redux preloadedState into a full html page using the renderFullPage function
  6. Send the response to the client res.send(

Client side

For the client side the index file is src/client/index.js

In this file, we use the redux preloadedState provided by the server to initialise a client side redux store.

We then use the React hydrate function to initialise React on the client side.

In the React components, any asynchronous data is fetched in componentDidMount. If data already exists, the component will not make the fetch.

componentDidMount() {
  // only fetch the data if there is no data
  if (!this.props.data) this.props.getData();
}

In this way, components won't make requests for data if the data has already been requested server side.

React Router

The difference in the react tree between server side and client side is as follows:

Server src/server/handleRender.js

<Provider store={store}>
  <StaticRouter location={req.url} context={{}}>
    <Router />
  </StaticRouter>
</Provider>

Client src/client/index.js

<Provider store={store}>
  <BrowserRouter>
    <Router />
  </BrowserRouter>
</Provider>

Everything else in the entire React tree is the same between server and client.

Contributing

Any issues, reports, feedback or bugs or pull requests are more than welcome.

However it is worth mentioning that the purpose of this repo is to create the simplest, most up-to-date, most robust universal async react redux boilerplate.

Therefore any pull request should aim to simplify, fix or update the current solution, not add new packages or complexity.

License

MIT License

Copyright (c) 2019 William Woodhead

Have a play around

Good luck with it! Please star or follow on twitter: @williamwoodhead

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].