Convert Figma logo to code with AI

react-boilerplate logoreact-boilerplate

🔥 A highly scalable, offline-first foundation with the best developer experience and a focus on performance and best practices.

29,534
6,092
29,534
130

Top Related Projects

Set up a modern web app by running one command.

The official, opinionated, batteries-included toolset for efficient Redux development

132,759

The React Framework

73,812

Next generation frontend tooling. It's fast!

31,388

Build Better Websites. Create modern, resilient user experiences with web fundamentals.

55,893

The best React-based framework with performance, scalability and security built in.

Quick Overview

React Boilerplate is a highly scalable, offline-first foundation for React applications. It provides a robust starting point for building complex, production-ready web applications using React, Redux, and other modern web technologies. The project aims to follow best practices and includes a comprehensive set of tools and configurations out of the box.

Pros

  • Comprehensive setup with best practices for React, Redux, and related technologies
  • Includes features like code splitting, offline-first functionality, and i18n support
  • Extensive documentation and active community support
  • Regular updates and maintenance to keep up with the latest trends and technologies

Cons

  • Steep learning curve for beginners due to its complexity and extensive feature set
  • May be overkill for smaller projects or simple applications
  • Opinionated structure and setup, which might not align with all developers' preferences
  • Requires some time to understand and customize the boilerplate to fit specific project needs

Code Examples

  1. Creating a Redux reducer:
import { createReducer } from '@reduxjs/toolkit';
import { someAction } from './actions';

const initialState = {
  // Initial state properties
};

const myReducer = createReducer(initialState, (builder) => {
  builder.addCase(someAction, (state, action) => {
    // Update state based on the action
  });
});

export default myReducer;
  1. Creating a React component with hooks:
import React, { useState, useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { someAction } from './actions';

const MyComponent = () => {
  const [localState, setLocalState] = useState(initialValue);
  const globalState = useSelector((state) => state.someSlice);
  const dispatch = useDispatch();

  useEffect(() => {
    // Side effect logic
  }, [dependencies]);

  const handleClick = () => {
    dispatch(someAction());
  };

  return (
    <div>
      {/* JSX content */}
    </div>
  );
};

export default MyComponent;
  1. Setting up a route:
import { Route } from 'react-router-dom';
import MyComponent from './MyComponent';

<Route exact path="/my-route" component={MyComponent} />

Getting Started

  1. Clone the repository:

    git clone https://github.com/react-boilerplate/react-boilerplate.git my-app
    cd my-app
    
  2. Install dependencies:

    npm install
    
  3. Start the development server:

    npm start
    
  4. Open your browser and navigate to http://localhost:3000 to see your app running.

  5. To build for production:

    npm run build
    

For more detailed instructions and customization options, refer to the project's documentation.

Competitor Comparisons

Set up a modern web app by running one command.

Pros of Create React App

  • Simpler setup and configuration, ideal for beginners
  • Official Facebook tool with regular updates and community support
  • Includes built-in testing framework and service worker support

Cons of Create React App

  • Less flexibility for advanced configurations
  • Larger bundle size due to included features
  • Ejecting required for custom webpack configurations

Code Comparison

Create React App:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(<App />, document.getElementById('root'));

React Boilerplate:

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'connected-react-router';
import App from 'containers/App';

ReactDOM.render(
  <Provider store={store}>
    <ConnectedRouter history={history}>
      <App />
    </ConnectedRouter>
  </Provider>,
  document.getElementById('app')
);

The React Boilerplate example shows more advanced setup with Redux and React Router integration, while Create React App provides a simpler entry point. React Boilerplate offers a more opinionated structure with additional features out-of-the-box, whereas Create React App focuses on simplicity and ease of use for getting started quickly with React development.

The official, opinionated, batteries-included toolset for efficient Redux development

Pros of Redux Toolkit

  • Simplifies Redux setup with built-in utilities for common tasks
  • Includes RTK Query for efficient API calls and data fetching
  • Reduces boilerplate code with createSlice and createAsyncThunk

Cons of Redux Toolkit

  • Less flexibility for custom Redux configurations
  • Steeper learning curve for developers new to Redux concepts
  • May introduce unnecessary complexity for smaller projects

Code Comparison

Redux Toolkit:

import { createSlice } from '@reduxjs/toolkit'

const counterSlice = createSlice({
  name: 'counter',
  initialState: 0,
  reducers: {
    increment: state => state + 1,
  },
})

React Boilerplate:

import { INCREMENT } from './constants';

const initialState = 0;

function counterReducer(state = initialState, action) {
  switch (action.type) {
    case INCREMENT:
      return state + 1;
    default:
      return state;
  }
}

Redux Toolkit simplifies reducer creation with createSlice, while React Boilerplate uses a more traditional Redux approach with switch statements and action constants.

132,759

The React Framework

Pros of Next.js

  • Built-in server-side rendering and static site generation
  • Automatic code splitting for faster page loads
  • Simplified routing with file-system based routing

Cons of Next.js

  • Steeper learning curve for developers new to server-side rendering
  • Less flexibility in project structure compared to custom setups
  • Potential overhead for simple applications that don't require SSR

Code Comparison

Next.js:

// pages/index.js
export default function Home() {
  return <h1>Welcome to Next.js!</h1>
}

React Boilerplate:

// app/containers/HomePage/index.js
import React from 'react';

export default function HomePage() {
  return <h1>Welcome to React Boilerplate!</h1>;
}

Next.js simplifies the creation of new pages with its file-system based routing, while React Boilerplate requires more manual setup but offers greater flexibility in project structure.

Next.js provides a more opinionated framework with built-in features like server-side rendering and automatic code splitting, making it easier to create performant applications out of the box. React Boilerplate, on the other hand, offers a more customizable starting point for React applications, allowing developers to have more control over the project setup and dependencies.

Both projects aim to improve the React development experience, but Next.js focuses on providing a complete framework, while React Boilerplate serves as a starting template for custom React applications.

73,812

Next generation frontend tooling. It's fast!

Pros of Vite

  • Faster development server and build times due to native ES modules
  • Lightweight and minimal configuration required out of the box
  • Supports multiple frameworks beyond React (Vue, Svelte, etc.)

Cons of Vite

  • Less opinionated structure, which may require more setup for larger projects
  • Smaller ecosystem and community compared to React Boilerplate
  • May require additional configuration for some advanced features

Code Comparison

React Boilerplate:

import React from 'react';
import { Helmet } from 'react-helmet-async';
import styled from 'styled-components';

const Wrapper = styled.div`
  // Styles here
`;

Vite:

import React from 'react'
import './App.css'

function App() {
  return <div className="App">
    {/* Content here */}
  </div>
}

Summary

Vite offers a faster, more lightweight development experience with broader framework support, while React Boilerplate provides a more structured, opinionated setup specifically for React projects. The choice between them depends on project requirements, team preferences, and the desired level of customization.

31,388

Build Better Websites. Create modern, resilient user experiences with web fundamentals.

Pros of Remix

  • Full-stack framework with built-in server-side rendering and data loading
  • Simplified routing system with nested routes and automatic code splitting
  • Better performance through intelligent asset loading and prefetching

Cons of Remix

  • Steeper learning curve due to its full-stack nature and unique concepts
  • Less flexibility in choosing backend technologies compared to React Boilerplate
  • Smaller ecosystem and community support as a newer framework

Code Comparison

Remix route example:

export default function Index() {
  return <h1>Welcome to Remix</h1>;
}

export function loader() {
  return json({ message: "Hello from the server!" });
}

React Boilerplate component example:

import React from 'react';
import { Helmet } from 'react-helmet-async';

export function HomePage() {
  return (
    <>
      <Helmet>
        <title>Home Page</title>
        <meta name="description" content="A React Boilerplate application homepage" />
      </Helmet>
      <h1>Welcome to React Boilerplate</h1>
    </>
  );
}

The Remix example showcases its integrated server-side data loading, while the React Boilerplate example demonstrates its use of React Helmet for managing document head tags.

55,893

The best React-based framework with performance, scalability and security built in.

Pros of Gatsby

  • Built-in performance optimizations, including code splitting and image optimization
  • Large ecosystem of plugins for easy integration of various features and data sources
  • Static site generation capabilities, resulting in faster load times and improved SEO

Cons of Gatsby

  • Steeper learning curve due to GraphQL integration and Gatsby-specific concepts
  • Potentially slower build times for large sites with many pages
  • Less flexibility for dynamic content compared to traditional React applications

Code Comparison

Gatsby:

import React from "react"
import { graphql } from "gatsby"

export default function Home({ data }) {
  return <div>{data.site.siteMetadata.title}</div>
}

export const query = graphql`
  query HomePageQuery {
    site {
      siteMetadata {
        title
      }
    }
  }
`

React Boilerplate:

import React from 'react';
import { Helmet } from 'react-helmet-async';

export function HomePage() {
  return (
    <article>
      <Helmet>
        <title>Home Page</title>
        <meta name="description" content="A React Boilerplate application homepage" />
      </Helmet>
      <div>HomePage Component</div>
    </article>
  );
}

The code comparison highlights Gatsby's use of GraphQL for data fetching, while React Boilerplate uses a more traditional React component structure with Helmet for managing document head tags.

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

react boilerplate banner
Start your next react project in seconds
A highly scalable, offline-first foundation with the best DX and a focus on performance and best practices


Created by Max Stoiber and maintained with ❤️ by an amazing team of developers.

Features

Quick scaffolding
Create components, containers, routes, selectors and sagas - and their tests - right from the CLI!
Instant feedback
Enjoy the best DX (Developer eXperience) and code your app at the speed of thought! Your saved changes to the CSS and JS are reflected instantaneously without refreshing the page. Preserve application state even when you update something in the underlying code!
Predictable state management
Unidirectional data flow allows for change logging and time travel debugging.
Next generation JavaScript
Use template strings, object destructuring, arrow functions, JSX syntax and more.
Next generation CSS
Write composable CSS that's co-located with your components for complete modularity. Unique generated class names keep the specificity low while eliminating style clashes. Ship only the styles that are on the page for the best performance.
Industry-standard routing
It's natural to want to add pages (e.g. `/about`) to your application, and routing makes this possible.
Industry-standard i18n internationalization support
Scalable apps need to support multiple languages, easily add and support multiple languages with `react-intl`.
Offline-first
The next frontier in performant web apps: availability without a network connection from the instant your users load the app.
Static code analysis
Focus on writing new features without worrying about formatting or code quality. With the right editor setup, your code will automatically be formatted and linted as you work.
SEO
We support SEO (document head tags management) for search engines that support indexing of JavaScript content. (eg. Google)

But wait... there's more!

  • The best test setup: Automatically guarantee code quality and non-breaking changes. (Seen a react app with 100% test coverage before?)
  • Native web app: Your app's new home? The home screen of your users' phones.
  • The fastest fonts: Say goodbye to vacant text.
  • Stay fast: Profile your app's performance from the comfort of your command line!
  • Catch problems: AppVeyor and TravisCI setups included by default, so your tests get run automatically on Windows and Unix.

There’s also a fantastic video on how to structure your React.js apps with scalability in mind. It provides rationale for the majority of boilerplate's design decisions.

Keywords: React.js, Redux, Hot Reloading, ESNext, Babel, react-router, Offline First, ServiceWorker, styled-components, redux-saga, FontFaceObserver

Quick start

  1. Make sure that you have Node.js v8.15.1 and npm v5 or above installed.
  2. Clone this repo using git clone --depth=1 https://github.com/react-boilerplate/react-boilerplate.git <YOUR_PROJECT_NAME>
  3. Move to the appropriate directory: cd <YOUR_PROJECT_NAME>.
  4. Run npm run setup in order to install dependencies and clean the git repo.
    At this point you can run npm start to see the example app at http://localhost:3000.
  5. Run npm run clean to delete the example app.

Now you're ready to rumble!

Please note that this boilerplate is production-ready and not meant for beginners! If you're just starting out with react or redux, please refer to https://github.com/petehunt/react-howto instead. If you want a solid, battle-tested base to build your next product upon and have some experience with react, this is the perfect start for you.

Documentation

Contributors

Thanks goes to these wonderful people (emoji key):

Max Stoiber
Max Stoiber

💻 📖 🤔 👀 ⚠️
Julien Benchetrit
Julien Benchetrit

💻 💬 📖 👀 🚧
Sara Federico
Sara Federico

💻 👀 💬 📖 🚧
Justin Greenberg
Justin Greenberg

💻 👀
Jon Winn
Jon Winn

💻 👀
Johan Meester
Johan Meester

💻 ⚠️ 📖
Yaroslav Kiliba
Yaroslav Kiliba

💻
Glen Ihrig
Glen Ihrig

💻
Somasundaram Ayyappan
Somasundaram Ayyappan

💻
Oliver Turner
Oliver Turner

💻
Samuel Sharpe
Samuel Sharpe

💻
Mihir Karandikar
Mihir Karandikar

💻
Vaibhav Verma
Vaibhav Verma

💻
Sébastien Dubois
Sébastien Dubois

💻
Chainarong Tangsurakit
Chainarong Tangsurakit

💻
Amila Welihinda
Amila Welihinda

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Supporters

This project would not be possible without the support of these amazing folks. Become a sponsor to get your company in front of thousands of engaged react developers and help us out!


License

This project is licensed under the MIT license, Copyright (c) 2019 Maximilian Stoiber. For more information see LICENSE.md.