Convert Figma logo to code with AI

bodyno logoreact-starter-kit

Start your first React App. By using React, Redux, and React-Router.

1,754
392
1,754
27

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

  1. 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;
  1. Example of a Redux action creator:
export const incrementCounter = () => ({
  type: 'INCREMENT_COUNTER'
});

export const decrementCounter = () => ({
  type: 'DECREMENT_COUNTER'
});
  1. 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:

  1. Clone the repository:

    git clone https://github.com/bodyno/react-starter-kit.git
    cd react-starter-kit
    
  2. Install dependencies:

    npm install
    
  3. Start the development server:

    npm start
    
  4. 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 Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

废弃警告

这个项目起始于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.