react-starter-kit
Start your first React App. By using React, Redux, and React-Router.
Top Related Projects
Set up a modern web app by running one command.
The web's most popular Jamstack front-end template (boilerplate) for building web applications with React
🔥 A highly scalable, offline-first foundation with the best developer experience and a focus on performance and best practices.
React + Redux starter kit / boilerplate with Babel, hot reloading, testing, linting and a working example app built in
Get started with React, Redux, and React-Router.
A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
Quick Overview
React Starter Kit is a comprehensive boilerplate for building web applications using React, Redux, and Webpack. It provides a solid foundation for developing modern, scalable, and maintainable React projects with a focus on best practices and developer experience.
Pros
- Includes a well-structured project setup with React, Redux, and Webpack pre-configured
- Offers hot module replacement for faster development and debugging
- Provides built-in support for CSS Modules and Sass
- Includes a robust testing setup with Jest and Enzyme
Cons
- May have a steeper learning curve for beginners due to its comprehensive nature
- Some included dependencies might become outdated over time if not regularly maintained
- The project structure might be overly complex for smaller applications
- Limited customization options without modifying the core boilerplate
Code Examples
- Example of a React component using CSS Modules:
import React from 'react';
import styles from './Button.module.css';
const Button = ({ onClick, children }) => (
<button className={styles.button} onClick={onClick}>
{children}
</button>
);
export default Button;
- Example of a Redux action creator:
export const incrementCounter = () => ({
type: 'INCREMENT_COUNTER'
});
export const decrementCounter = () => ({
type: 'DECREMENT_COUNTER'
});
- Example of a Redux reducer:
const initialState = {
count: 0
};
const counterReducer = (state = initialState, action) => {
switch (action.type) {
case 'INCREMENT_COUNTER':
return { ...state, count: state.count + 1 };
case 'DECREMENT_COUNTER':
return { ...state, count: state.count - 1 };
default:
return state;
}
};
export default counterReducer;
Getting Started
To get started with React Starter Kit:
-
Clone the repository:
git clone https://github.com/bodyno/react-starter-kit.git cd react-starter-kit
-
Install dependencies:
npm install
-
Start the development server:
npm start
-
Open your browser and navigate to
http://localhost:3000
to see the app running.
Competitor Comparisons
Set up a modern web app by running one command.
Pros of create-react-app
- Official React toolchain with extensive community support and regular updates
- Simplified setup process with zero configuration required
- Integrated development server with hot reloading and error reporting
Cons of create-react-app
- Less flexibility in configuration options without ejecting
- Larger bundle size due to inclusion of unnecessary dependencies
- Limited customization of build process without advanced knowledge
Code Comparison
react-starter-kit:
import React from 'react';
import { render } from 'react-dom';
import { Router, browserHistory } from 'react-router';
import routes from './routes';
render(
<Router history={browserHistory} routes={routes} />,
document.getElementById('root')
);
create-react-app:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
The main difference in the code examples is that react-starter-kit uses React Router for routing, while create-react-app provides a simpler setup with just the main App component. create-react-app also includes additional features like web vitals reporting and strict mode by default.
The web's most popular Jamstack front-end template (boilerplate) for building web applications with React
Pros of React Starter Kit
- More comprehensive and feature-rich, offering a full-stack solution
- Better documentation and community support
- Regular updates and maintenance
Cons of React Starter Kit
- Steeper learning curve due to its complexity
- May include unnecessary features for smaller projects
- Requires more setup and configuration
Code Comparison
React Starter Kit:
import React from 'react';
import { graphql } from 'react-relay';
import Layout from '../../components/Layout';
import Page from '../../components/Page';
export default function Home({ data }) {
return (
<Layout>
<Page {...data.page} />
</Layout>
);
}
React Starter Kit (bodyno):
import React from 'react'
import { Link } from 'react-router'
import { Counter } from 'components/Counter'
import classes from './HomeView.scss'
export const HomeView = () => (
<div>
<h4>Welcome!</h4>
<Counter />
<Link to='/counter'>Go to Counter</Link>
</div>
)
The code comparison shows that React Starter Kit uses GraphQL and has a more structured approach, while the bodyno version uses a simpler component structure. React Starter Kit's code suggests a more scalable and feature-rich setup, whereas the bodyno version appears more straightforward and easier to grasp for beginners.
🔥 A highly scalable, offline-first foundation with the best developer experience and a focus on performance and best practices.
Pros of react-boilerplate
- More comprehensive and feature-rich, offering a wider range of tools and configurations
- Better documentation and community support, with regular updates and maintenance
- Includes advanced features like code splitting and offline-first functionality
Cons of react-boilerplate
- Steeper learning curve due to its complexity and extensive feature set
- May be overkill for smaller projects or beginners learning React
- Requires more setup and configuration time before starting development
Code Comparison
react-boilerplate:
import { createSelector } from 'reselect';
import { initialState } from './reducer';
const selectHome = state => state.home || initialState;
const makeSelectUsername = () =>
createSelector(
selectHome,
homeState => homeState.username
);
react-starter-kit:
import React from 'react';
import { connect } from 'react-redux';
const mapStateToProps = state => ({
user: state.user
});
export default connect(mapStateToProps)(YourComponent);
The code comparison shows that react-boilerplate uses more advanced state management techniques with reselect, while react-starter-kit uses a simpler Redux connection approach.
React + Redux starter kit / boilerplate with Babel, hot reloading, testing, linting and a working example app built in
Pros of React Slingshot
- More comprehensive documentation and setup instructions
- Includes additional features like error tracking and offline support
- Regularly maintained with frequent updates
Cons of React Slingshot
- Potentially overwhelming for beginners due to its extensive feature set
- Slightly larger initial bundle size due to additional dependencies
Code Comparison
React Slingshot:
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import routes from './routes';
React Starter Kit:
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import routes from './routes';
Summary
Both React Slingshot and React Starter Kit provide solid foundations for React projects. React Slingshot offers a more feature-rich environment with comprehensive documentation, making it suitable for developers who want a robust starting point. However, this comes at the cost of a slightly steeper learning curve and larger initial bundle size.
React Starter Kit, on the other hand, provides a more minimalistic approach, which may be preferable for developers who want more control over their project structure and dependencies.
The code comparison shows that both projects use similar core dependencies and setup, with minor differences in import statements and overall structure.
Get started with React, Redux, and React-Router.
Pros of react-redux-starter-kit
- Includes Redux integration out of the box, simplifying state management
- More comprehensive testing setup with Karma, Mocha, and Chai
- Better organized project structure with separate directories for routes, layouts, and components
Cons of react-redux-starter-kit
- More complex setup may be overwhelming for beginners
- Less frequently updated compared to react-starter-kit
- Heavier initial bundle size due to additional dependencies
Code Comparison
react-starter-kit:
import React from 'react'
import ReactDOM from 'react-dom'
import App from './components/App'
ReactDOM.render(<App />, document.getElementById('root'))
react-redux-starter-kit:
import React from 'react'
import ReactDOM from 'react-dom'
import createStore from './store/createStore'
import App from './components/App'
const store = createStore(window.__INITIAL_STATE__)
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
)
The react-redux-starter-kit example shows the integration of Redux with the store creation and Provider wrapper, while the react-starter-kit example is simpler but lacks built-in state management.
A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
Pros of react-redux-universal-hot-example
- More comprehensive and feature-rich, including server-side rendering and Redux integration
- Includes a wider range of technologies and tools, such as Express, Socket.io, and Helmet
- Better documentation and more detailed explanations in the README
Cons of react-redux-universal-hot-example
- More complex and potentially overwhelming for beginners
- Larger codebase with more dependencies, which may lead to longer build times
- Less frequently updated compared to react-starter-kit
Code Comparison
react-redux-universal-hot-example:
import React from 'react';
import { renderToString } from 'react-dom/server';
import { match, RouterContext } from 'react-router';
import { Provider } from 'react-redux';
import createStore from './redux/create';
react-starter-kit:
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import App from './components/App';
import './index.css';
The code comparison shows that react-redux-universal-hot-example includes more advanced features like server-side rendering and Redux integration, while react-starter-kit focuses on a simpler client-side setup.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
åºå¼è¦å
è¿ä¸ªé¡¹ç®èµ·å§äºReduxçæçå¼å§ï¼ç®çæ¯æä¾ä¸ä¸ªæèæ¶è®©å端们快éä¸æåå¼å§ãä¹åï¼å·¥å ·åæä½³å®è·µè¢«ä¸æçé©æ°ã为äºè·å¾ææ°çä½éªï¼ææ¨èä½ ä½¿ç¨ç±»ä¼¼äºcreate-react-appè¿ç§å¯ä»¥æ¯æReactæ ¸å¿åReduxçèææ¶ã
å½ç¶è¿æ¯æ¬¢è¿ä½ 继ç»ä½¿ç¨è¿ä¸ªé¡¹ç®å¦æä½ è§å¾è¿ä¸ªé¡¹ç®æ´éåä½ ãå¦æä½ æ¯ä¸ªè¿½æ±æ°çæç人ï¼æè¿æ¯å¼ºçæ¨èä½ ä½¿ç¨å ¶å®æ´æ°æ´é¢ç¹ç项ç®ã
谢谢大家å¨è¿å»è¿äºå¹´ä¸ºè¿ä¸ªé¡¹ç®çè´¡ç®ãThanks everyone.
React Starter Kit
Reactå¼åä¸æ好ç¨çèææ¶ã
è¿ä¸ªå¯å¨å ç设计æ¯ä¸ºäºè®©ä½ 使ç¨ä¸æ´å¥ææ°æé ·çå端ææ¯ï¼ææé½æ¯å¯é ç½®ï¼å¯ç¹æ§ï¼åºäºwebpackå·²ç»æä¾ä»£ç çå è½½ï¼ä½¿ç¨sassé¢å¤çcssï¼åå æµè¯ï¼ä»£ç è¦ççæ¥åï¼ä»£ç åå²ççæ´å¤ã
è¿ä¸ªé¡¹ç®æ主è¦çç®çæ¯å°½å¯è½ææçä¿çãç®çä¸æ¯è¦ä½ ä¸å®æç §è¿ä¸ªç»æå»å®æä½ ç项ç®ï¼è°å¨ä½¿å端å¼åæ´å¥å£®ï¼æ´ç®åè¿ææéè¦çæ¯æ´å¿«ä¹ãä½ å¯ä»¥è·å¾ä»¥ä¸çææç¹æ§ï¼
æåï¼å¦æ没æ大家çè´¡ç®ï¼è¿ä¸ªé¡¹ç®æ¯ä¸å¯è½å¦æ¤å¥å£®çã
ææç¸å ³åºå·²åå¤å¥½ï¼éæ¶çå¾ è°ç¨ã
ç¹æ§
éæ±é ç½®
- node
^4.5.0
- npm
^3.0.0
å¼å§
ç¡®è®¤å¥½ä½ çç¯å¢é ç½®ï¼ç¶åå°±å¯ä»¥å¼å§ä»¥ä¸æ¥éª¤ã
$ git clone https://github.com/bodyno/react-starter-kit.git
$ cd react-starter-kit
$ npm install # Install project dependencies
$ npm start # Compile and launch
å¦æä¸å顺å©ï¼ä½ ä¼çå°å¦ä¸:
å¼åè¿ç¨ä¸ï¼ä½ ç¨å¾æå¤çä¼æ¯npm start
ï¼ä½æ¯è¿éè¿æå¾å¤å
¶å®çå¤çï¼
npm run <script> | 解é |
---|---|
start | æå¡å¯å¨å¨3000端å£ï¼ä»£ç çæ¿æ¢å¼å¯ã |
compile | ç¼è¯ç¨åºå°distç®å½ä¸ï¼é»è®¤ç®å½~/distï¼ã |
dev | ä¸npm start ç¸å, ä½æ¯å¯å¨nodemonå®æ¤è¿ç¨ã |
dev:no-debug | ä¸npm run dev ä½æ¯ç¦ç¨devtoolï¼å¼åå·¥å
·ï¼ã |
test | å¼å¯Karmaæµè¯å¹¶çæè¦ççæ¥åã |
test:dev | å¼å¯Karmaæµè¯å¹¶çå¬æ¹åéæ¶éæ°æµè¯ï¼ä½æ¯çæè¦ççæ¥åã |
deploy | å¯å¨ä»£ç æ£æ¥ï¼æµè¯ï¼å¦ææåï¼ç¼è¯å°distç®å½ä¸ã |
deploy:dev | ä¸deploy ç¸åï¼ä½æ¯NODE_ENV å¼ä¸º"development"ã |
deploy:prod | ä¸deploy ç¸åï¼ä½æ¯NODE_ENV å¼ä¸º"production"ã |
lint | æ£æ¥ææ.jsæ件æ¯å¦è§èã |
lint:fix | æ£æ¥ææ.jsæ件æ¯å¦è§è并修å¤å®ä»¬ã æ´å¤ |
ç¨åºç®å½
è¿ä¸ªé¡¹ç®çç»æ使ç¨çæ¯ **fractal(ä¸è§åç¢çå½¢ï¼éå大å项ç®)***ï¼æ¹æ³çåç»ä¸»è¦æ¯ä¾ç §ç¹æ§èä¸æ¯æ件类åã注æï¼è¿ä¸ªç®å½ç»æåªæ¯ä¸ä¸ªæå¼ï¼å¹¶ä¸ä¸å®è¦æè¿ä¸ªæ¥ãè¿ç§ç»æè°å¨è®©ç¨åºæ´å®¹ææ©å±ï¼æ³äºè§£æ´å¤è¯·ç¹å»è¿éã
.
âââ bin # å¯å¨èæ¬
âââ blueprints # redux-cliçèå¾
âââ build # æææå
é
置项
â âââ webpack # webpackçæå®ç¯å¢é
ç½®æ件
âââ config # 项ç®é
ç½®æ件
âââ server # Express ç¨åº (ä½¿ç¨ webpack ä¸é´ä»¶)
â âââ main.js # æå¡ç«¯ç¨åºå
¥å£æ件
âââ src # ç¨åºæºæ件
â âââ main.js # ç¨åºå¯å¨å渲æ
â âââ components # å
¨å±å¯å¤ç¨ç表ç°ç»ä»¶(Presentational Components)
â âââ containers # å
¨å±å¯å¤ç¨ç容å¨ç»ä»¶
â âââ layouts # 主页ç»æ
â âââ static # éææ件(ä¸è¦å°å¤importedæºæ件)
â âââ styles # ç¨åºæ ·å¼
â âââ store # Reduxæå®å
â â âââ createStore.js # å建å使ç¨redux store
â â âââ reducers.js # Reducer注åå注å
¥
â âââ routes # 主路ç±åå¼æ¥åå²ç¹
â âââ index.js # ç¨storeå¯å¨ä¸»ç¨åºè·¯ç±
â âââ Root.js # 为ä¸ä¸æproviderså
ä½ç»ä»¶
â âââ Home # ä¸è§åè·¯ç±
â âââ index.js # è·¯ç±å®ä¹å代ç å¼æ¥åå²
â âââ assets # ç»ä»¶å¼å
¥çéæèµæº
â âââ components # ç´è§Reactç»ä»¶
â âââ container # è¿æ¥actionsåstore
â âââ modules # reducers/constants/actionsçéå
â âââ routes ** # ä¸è§ååè·¯ç±(** å¯éæ©ç)
âââ tests # åå
æµè¯
æ ·å¼
ææçcssåsassé½æ¯æä¼è¢«é¢å¤çãåªè¦è¢«å¼å ¥ï¼é½ä¼ç»è¿PostCSSå缩ï¼å åç¼ãå¨ç产ç¯å¢ä¸ä¼æåå°ä¸ä¸ªcssæ件ä¸ã
æå¡ç«¯
è¿ä¸ªé¡¹ç®çæå¡ç«¯ä½¿ç¨Koaãéè¦æ³¨æçæ¯ï¼åªæä¸ä¸ªç®çé£å°±æ¯æä¾äºwebpack-dev-middleware
å webpack-hot-middleware
ï¼ä»£ç çæ¿æ¢ï¼ã使ç¨èªå®ä¹çKoaç¨åºæ¿æ¢webpack-dev-serverï¼è®©å®æ´å®¹æå®ç°universal 渲æå为äºä¸ä½¿è¿ä¸ªå
è¿äºåºå¤§ã
æå ä¼å
Babel被é ç½®babel-plugin-transform-runtimeå¯ä»¥è®©ä»£ç æ´ä¼åãå¦å¤ï¼å¨ç产ç¯å¢ï¼æ们使ç¨react-optimizeæ¥ä¼åReact代ç ã
å¨ç产ç¯å¢ä¸ï¼webpackä¼å¯¼åºä¸ä¸ªcssæ件并å缩Javascriptï¼å¹¶æjs模åä¼åå°æ好çæ§è½ã
éæé¨ç½²
å¦æä½ æ£å¨ä½¿ç¨nginxå¤çç¨åºï¼ç¡®ä¿ææçè·¯ç±é½ç´æ¥æå ~/dist/index.html
æ件ï¼ç¶å让react-routerå¤çå©ä¸çäºãå¦æä½ ä¸æ¯å¾ç¡®å®åºè¯¥æä¹åï¼ææ¡£å¨è¿éãExpresså¨èææ¶ä¸ç¨äºæ©å±æå¡å代çAPIï¼æè
å
¶å®ä½ æ³è¦åçäºï¼è¿å®å
¨åå³äºä½ ã
谢谢大家
å¦æ没æ大家çè´¡ç®ï¼è¿ä¸ªé¡¹ç®æ¯ä¸å¯è½è¯ççï¼ æè°¢ææ为è¿ä¸ªé¡¹ç®ååºè´¡ç®ç人ã
This program is inspired by davezuko
- Justin Greenberg - For all of your PR's, getting us to Babel 6, and constant work improving our patterns.
- Roman Pearah - For your bug reports, help in triaging issues, and PR contributions.
- Spencer Dixin - For your creation of redux-cli.
- Jonas Matser - For your help in triaging issues and unending support in our Gitter channel.
Thanks you guys all the time.
Top Related Projects
Set up a modern web app by running one command.
The web's most popular Jamstack front-end template (boilerplate) for building web applications with React
🔥 A highly scalable, offline-first foundation with the best developer experience and a focus on performance and best practices.
React + Redux starter kit / boilerplate with Babel, hot reloading, testing, linting and a working example app built in
Get started with React, Redux, and React-Router.
A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot