Skip to content

Latest commit

 

History

History
50 lines (46 loc) · 1.35 KB

File metadata and controls

50 lines (46 loc) · 1.35 KB

react-ssr-startkit

A web's scaffolding tool for react ssr webapps.using React, Redux, Rematch(A redux framework) and Scss.

Goal

This project can help you start the react ssr project in seconds. You can thing of it as a nodejs application. It integrated HMR, Proxy, Test, Lint, Server Logger

Usage

git clone https://github.com/zedwang/react-ssr-startkit.git
cd react-ssr-startkit
npm install
npm start

Then visit localhost:8080 in your browser.

Deploy

npm build

Will genarate a dist directory

dist
  bin
    server.boundle.js # app entry
  public
    ... #some js css images etc

Tips

The server side fetching data

client:

class Home extends React.Component {
    // some logic
}
// modelType/action
// see: https://rematch.gitbooks.io/rematch/docs/api.html#storedispatch
Home.serverFetch = {type: 'repos/fetchData'};

server:

routes
    .filter(route => matchPath(req.url, route))
    .map(route => route.component)
    .filter(comp => comp.serverFetch)
    .map(comp => {
        const {type, payload} = comp.serverFetch;
        return dispatch({type, payload});
    });