Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chikara-chan/react-isomorphic-boilerplate
π An universal React isomorphic boilerplate for building server-side render web app.
https://github.com/chikara-chan/react-isomorphic-boilerplate
babel boilerplate eslint isomorphic koa2 react redux server-side-rendering webpack
Last synced: 3 days ago
JSON representation
π An universal React isomorphic boilerplate for building server-side render web app.
- Host: GitHub
- URL: https://github.com/chikara-chan/react-isomorphic-boilerplate
- Owner: chikara-chan
- License: mit
- Created: 2016-12-16T02:27:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-29T19:51:10.000Z (about 7 years ago)
- Last Synced: 2025-01-12T05:06:13.932Z (10 days ago)
- Topics: babel, boilerplate, eslint, isomorphic, koa2, react, redux, server-side-rendering, webpack
- Language: JavaScript
- Homepage: https://chikara-chan.github.io/react-isomorphic-boilerplate/
- Size: 1.15 MB
- Stars: 653
- Watchers: 26
- Forks: 141
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# React Isomorphic Boilerplate
An universal React isomorphic boilerplate for building server-side render web app.
[![dependencies Status](https://david-dm.org/chikara-chan/react-isomorphic-boilerplate/status.svg)](https://david-dm.org/chikara-chan/react-isomorphic-boilerplate) [![devDependencies Status](https://david-dm.org/chikara-chan/react-isomorphic-boilerplate/dev-status.svg)](https://david-dm.org/chikara-chan/react-isomorphic-boilerplate?type=dev) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/chikara-chan/react-isomorphic-boilerplate/pulls) [![npm](https://img.shields.io/npm/l/express.svg)](https://github.com/chikara-chan/react-isomorphic-boilerplate/blob/master/LICENSE)
## Introduction
This repository is an universal React isomorphic boilerplate for developer to quickly build a super fast and powerful web app that can be rendered both on the client and on the server using the most cutting-edge technology. Compared to others, this boilerplate has more pithily and more elegant configuration file based on environment variables, one for development, one for production. In addition, the directory structure is organized corresponding to mvc principle aim at the best practice.
## Technology Stack
- [React](https://github.com/facebook/react)
- [React Router](https://github.com/ReactTraining/react-router)
- [Redux](https://github.com/reactjs/redux)
- [Redux+](https://github.com/xgrommx/awesome-redux)
- [Sass](https://github.com/sass/sass)
- [PostCSS](https://github.com/postcss/postcss)
- [CSS Modules](https://github.com/css-modules/css-modules)
- [Koa](https://github.com/koajs/koa)
- [Koa+](https://github.com/koajs)
- [Webpack](https://github.com/webpack/webpack)
- [Webpack+](https://webpack.js.org/loaders/)
- [Babel](https://github.com/babel/babel)
- [Babel+](http://babeljs.io/docs/plugins/)
- [ESLint](https://github.com/eslint/eslint)
- [Hot Module Replacement](https://webpack.github.io/docs/hot-module-replacement.html)
- [Code Splitting](https://webpack.github.io/docs/code-splitting.html)
- ~~Database~~
- ~~Test Framework~~## Getting Started
- Require Node.js v6 or later.
- `npm install` to install dependencies and devDependencies.
- `npm run dev` to start up the development environment.
- `npm run build` to compile and bundle the client and server files.
- `npm start` to deploy the production server.## What's included
```
react-isomorphic-boilerplate/ // root directory
βββ build/ // webpack config directory
β βββ webpack.dev.config.js // config for webpack when run development bundle
β βββ webpack.prod.config.js // config for webpack when run production bundle
βββ client/ // client directory
β βββ about/ // `about` module
β βββ common/ // `common` module
β βββ home/ // `home` module
β βββ shared/ // shared module
β βββ explore/ // `explore` module
β βββ index.js // client entry file
β βββ routes.js // client route config
βββ dist/ // bundle output directory
β βββ client/ // the client side output directory
β βββ server/ // the server side output directory
βββ server/ // server directory
β βββ controllers/ // controllers in server
β βββ middlewares/ // custom middlewares in server
β βββ models/ // models in server
β βββ routes/ // routes in server
β βββ app.js // create koa instance in server
β βββ server.dev.js // entry file in development mode
β βββ server.prod.js // entry file in production mode
βββ views/ // views directory
β βββ dev/ // output files generated by tpl in development mode
β βββ prod/ // output files generated by tpl in production mode
β βββ tpl // templates injected by html-webpack-plugin
βββ .editorconfig // uniform the text editor behavior
βββ .eslintignore // which paths should be omitted from linting
βββ .eslintrc.json // specific rules for eslint
βββ .gitattributes // uniform the new line perform behavior
βββ .gitignore // ignore the specific files when using git
βββ LICENSE // license information
βββ package.json // npm entry file
βββ README.md // just what you see now
βββ yarn.lock // lock file autogenerated by yarn
```## Why Isomorphic
#### SEO
An application that can only run in the client-side cannot serve HTML to crawlers, so it will have poor [SEO](https://en.wikipedia.org/wiki/Search_engine_optimization) by default. Web crawlers function by making a request to a web server and interpreting the result. but if the server returns a blank page, itβs not of much value. There are workarounds, but not without jumping through some hoops.
#### Performance
By the same token, if the server doesnβt render a full page of HTML but instead waits for client-side JavaScript to do so, users will experience a few critical seconds of blank page or loading spinner before seeing the content on the page. There are plenty of studies showing the drastic effect a slow site has on users, and thus revenue.
#### Maintainability
While the ideal case can lead to a nice, clean separation of concerns, inevitably some bits of application logic or view logic end up duplicated between client and server, often in different languages. Common examples are date and currency formatting, form validations, and routing logic. This makes maintenance a nightmare, especially for more complex apps.
## Problem exists yet
#### [FOUC](https://www.google.com.hk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0ahUKEwimhPqTrofRAhXHkJQKHTEYCfMQFggjMAE&url=https%3a%2f%2fen%2ewikipedia%2eorg%2fwiki%2fFlash_of_unstyled_content&usg=AFQjCNGjAnNtZtjPb5oLsT9Wlf9az7hXTw)
It happens when run in development mode. This is caused by deprecated using [extract-text-webpack-plugin](https://github.com/webpack/extract-text-webpack-plugin) in development for getting a seamless hmr experience.(Why deprecated? See this [Issue](https://github.com/webpack/extract-text-webpack-plugin/issues/30)) If you are not an OCD, go ahead, ignore it.
#### Mismatch
It happens also when run in development mode. This is caused by when you update the react component code and reload the page, the markup generated mismatches that on server render. However, once you restart the server, the checksum will be valid. So it is harmless, ignore it also.
## Links
[http://www.jianshu.com/p/0ecd727107bb](http://www.jianshu.com/p/0ecd727107bb)
## License
[MIT](https://github.com/chikara-chan/react-isomorphic-boilerplate/blob/master/LICENSE)