All Projects โ†’ vslio โ†’ Universal React Base

vslio / Universal React Base

[OUTDATED] Super basic example to get you started with Universal (๐Ÿ˜ฆ) React/Redux (+ API requests). Lightweight and straightforward.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Universal React Base

Pwa
An opinionated progressive web app boilerplate
Stars: โœญ 353 (+5783.33%)
Mutual labels:  webpack, universal, postcss
Reactql
Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
Stars: โœญ 1,833 (+30450%)
Mutual labels:  webpack, universal, postcss
Hops
Universal Development Environment
Stars: โœญ 158 (+2533.33%)
Mutual labels:  webpack, universal, postcss
Electron React Webpack Boilerplate
Minimal Electron, React, PostCSS and Webpack boilerplate to help you get started with building your next app.
Stars: โœญ 312 (+5100%)
Mutual labels:  webpack, postcss
Support
JS.coach is a manually curated list of packages related to React, Webpack, Babel and PostCSS
Stars: โœญ 305 (+4983.33%)
Mutual labels:  webpack, postcss
React Redux Boilerplate
Awesome React Redux Workflow Boilerplate with Webpack 4
Stars: โœญ 307 (+5016.67%)
Mutual labels:  webpack, postcss
Shopify Theme Lab
Shopify theme development environment using Liquid, Vue and Tailwind CSS ๐Ÿงช
Stars: โœญ 250 (+4066.67%)
Mutual labels:  webpack, postcss
Nuxt Purgecss
Drop superfluous CSS! A neat PurgeCSS wrapper for Nuxt.js
Stars: โœญ 356 (+5833.33%)
Mutual labels:  webpack, postcss
Isomorphic React
A simple but powerful React application built on a standards-compliant back-end
Stars: โœญ 318 (+5200%)
Mutual labels:  webpack, universal
React Mobx Typescript Boilerplate
A bare minimum frontend boilerplate with React 16.7, Typescript 3.2 and Webpack 4
Stars: โœญ 378 (+6200%)
Mutual labels:  webpack, postcss
Hugo Theme Hello Friend
Pretty basic theme for Hugo that covers all of the essentials. All you have to do is start typing!
Stars: โœญ 586 (+9666.67%)
Mutual labels:  webpack, postcss
Isomorphic Webpack
Abstracts universal consumption of application code base using webpack.
Stars: โœญ 294 (+4800%)
Mutual labels:  webpack, universal
Webpack Blocks
๐Ÿ“ฆ Configure webpack using functional feature blocks.
Stars: โœญ 2,992 (+49766.67%)
Mutual labels:  webpack, postcss
Kratos Boilerplate
๐Ÿ”ฅ A simple boilerplate for creating statics PWA using Webpack, Pug, PostCSS and CSS Modules
Stars: โœญ 308 (+5033.33%)
Mutual labels:  webpack, postcss
Reactgo
Your One-Stop solution for a full-stack universal Redux App!
Stars: โœญ 2,784 (+46300%)
Mutual labels:  webpack, universal
Naomi
Sublime Text enhanced syntax highlighting for JavaScript ES6/ES7/ES2015/ES2016/ES2017+, Babel, FlowType, React JSX, Styled Components, HTML5, SCSS3, PHP 7, phpDoc, PHPUnit, MQL4. Basic: Git config files.
Stars: โœญ 544 (+8966.67%)
Mutual labels:  webpack, postcss
Poi
โšกA zero-config bundler for JavaScript applications.
Stars: โœญ 5,291 (+88083.33%)
Mutual labels:  webpack, postcss
Universal
Seed project for Angular Universal apps featuring Server-Side Rendering (SSR), Webpack, CLI scaffolding, dev/prod modes, AoT compilation, HMR, SCSS compilation, lazy loading, config, cache, i18n, SEO, and TSLint/codelyzer
Stars: โœญ 669 (+11050%)
Mutual labels:  webpack, universal
Frontend Webpack Boilerplate
Simple starter webpack 5 project template supporting SASS/PostCSS, Babel ES7, browser syncing, code linting. Easy project setup having multiple features and developer friendly tools.
Stars: โœญ 242 (+3933.33%)
Mutual labels:  webpack, postcss
pwa
An opinionated progressive web app boilerplate
Stars: โœญ 355 (+5816.67%)
Mutual labels:  postcss, universal

Universal React (& Redux) base

What is it

This is a basic boilerplate to help you get started with React & Redux. What you need to know about it:

  • The main focus of this base is to demonstrate how to start a Universal React & Redux app in a simple and concise way, using just a minimum amount of baggage
  • It will show you how to fetch a component's data from an API server and ultimately construct and send the final HTML to the client, after all the required data is fetched
  • It assumes you have at least a basic understanding of how React, Redux and Immutable data structures work

What's left to do

  • [ ] Add user authentication (that's what the form is there for) and restrict access to specific routes/components
  • [ ] Add ImmutableJS
  • [ ] Don't dispatch the action in componentDidMount if the data has already been fetched from server-side rendering
  • [ ] Further improve the codebase (feel free to make suggestions, PRs etc)

The stack

  • [x] Express & json-server
  • [x] Webpack
  • [x] React
  • [x] Redux
  • [x] React Helmet
  • [x] PostCSS, CSS Modules & cssnext
  • [ ] ImmutableJS

Installation

Note: The current build hasn't been tested on Windows.

Clone this repository:

git clone [email protected]:vslio/universal-react-base.git project-folder/

Make sure you install json-server globally for the API server to work: Note: You might need to prepend sudo depending on the permissions of your user's node_modules folder.

npm install -g [email protected]

If you'd like to use a style guide, I would suggest StandardJS. You will need to install it globally:

npm install -g standard

Make sure to visit the link above for instructions on how to install the necessary plugin for your favourite code editor.

Fire up the console, navigate to the cloned repository and install the project's dependencies:

cd project-folder/
npm install # Install the project's dependencies
npm run build # Build the production files for the first time

To start development:

npm run dev

To build the project for production:

npm run build

To run the production code (the production files are rebuilt automatically every time):

npm start

The project is accessible on http://localhost:3000 and the API server on http://localhost3001.

Structure

.
โ”œโ”€โ”€ db                      # DB file for the mock API (used by json-server)
โ”œโ”€โ”€ dist                    # Final asset bundles (JS, images etc)
โ””โ”€โ”€ src                     # The source เฒ _เฒ 
    โ”œโ”€โ”€ client              # Bootstrap file for the client-side
    โ”œโ”€โ”€ server              # Server-side only files
    โ”‚   โ”œโ”€โ”€ lib             # Server libraries
    โ”‚   โ””โ”€โ”€ views           # Server template files
    โ””โ”€โ”€ shared              # Universal files - anything react/redux related
        โ”œโ”€โ”€ actions         # Redux action types and action creators
        โ”œโ”€โ”€ components      # React components (includes containers)
        โ”œโ”€โ”€ lib             # Redux middleware and other libraries
        โ”œโ”€โ”€ reducers        # Redux reducers
        โ”œโ”€โ”€ store           # Redux store configuration
        โ””โ”€โ”€ styles          # Top level and reusable styles (not component-specific)
            โ”œโ”€โ”€ base        # Base styles (type, variables, really top level stuff)
            โ””โ”€โ”€ modules     # Common styles that can be composed (or @extend-ed in SASS-land) in components

Components

Some Components are defined as Stateless Functions instead of classes:

import React from 'react'
import style from './home.css'

export default () => (
  <header>
    <h3 className={style.heading}>Homepage</h3>
    <span className={style.description}>This is the homepage.</span>
  </header>
)

This is the recommended option when the component we're creating does not need to retain internal state and doesn't have any of the lifecycle methods. For more information check this section of the React documentation. Caveat: Hot reloading doesn't work with stateless functions. There is no support at this stage, but it could happen. This is the case because I am using the experimental react-transform-hmr. This will likely be removed in the future, in favour of Webpack's native HMR.

CSS

Using PostCSS, CSS Modules and cssnext. Despite being a big fan of SASS and global CSS in general, I decided to give CSS Modules a go. There are a few quirks to overcome and you need to 'retrain' your brain to do things in a different way, but, ultimately, I believe it's the way to go for React projects. Please, make sure to read the article I linked above regarding CSS Modules. It's probably the most thorough you will find and it outlines most of the pros and cons of using them.

... TBC. :-)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].