Awesome Open Source
Awesome Open Source

⚡ (V2) Universal JS - Server Side Rendering, Code Splitting and Hot Module Reloading ⚡

💭 What is it?

Universal JS: - JavaScript that can run on both the server and client (or any other JS platform for that matter) !

Hot Module Reloading: - Replaces modules that have been changed in real time while preserving the state.

Server Side Rendering: - Renders Pages on the initial for fast page loads and search engine optimization

Code Splitting: - Split code into bundles so that code is asynchronously loaded by the client.

⚙ How?

The Basic setup goes like this...

An express server handles a request, renders the page on the server, then sends it back to the client. The code is bundled into chunks on build time which are requested by the client when needed for that route.

When in development mode, the express server handles a request and uses the webpack.config.development.js configuration as middleware to listen for file changes, build, then and push them to the client.


This project is an updated version of this project. With the biggest updates being migrations to React Router 4 and Hot Module Reloading 3

The main goal of this project remains the same; A simple and no BS approach to a Universal JS, Server Side Rendering, Code Splitting and Hot Module Reloading using the following technologies:

  • React
  • Redux
  • React Router 4
  • Webpack 2
  • Hot Module Reloader 3
  • Babel
  • Express
  • webpack-dev-middleware
  • webpack-hot-middleware
  • immutablejs

🛠 Setup

First install the dependencies in the root directory of this project run. npm install

🤖 Running

For Development run npm run development

This will start a development server on localhost:8080 that utilizes hot module reloading for both React components and Redux reducers.

For Production run npm run build && npm run production.

This will build all your assets and write them to a /build folder in the root directory of this project. The script will then start an express server on localhost:8080 that will utilize server side rendering and route based code splitting.

hmr-ssr

🗒 Notes

Hot Module Reloading does not work with System.import, as such there are two route sources.

  • The first one src/universal/routes/static.js is for static routes (no code splitting) that is for the development environment to work nicely with React Hot Loader 3
  • The second route source src/universal/routes/async.js is for asynchronous routes (Code splitting using System.import).

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
javascript (68,028
react (5,153
redux (1,149
react-router (202
server-side-rendering (143
react-redux (114
webpack2 (110
hot-reload (72
react-router-v4 (63
code-splitting (43
universal-react (14

Find Open Source By Browsing 7,000 Topics Across 59 Categories