All Projects → mz026 → Universal Redux Template

mz026 / Universal Redux Template

A clean, extensible react + redux boilerplate with universal/isomorphic rendering, testing and more

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Universal Redux Template

Oh My Fullstack
🚀 Full stack web application skeleton (Next.js, Redux, RxJS, Immutable, Express)
Stars: ✭ 99 (-78.98%)
Mutual labels:  starter-kit, isomorphic, boilerplate
Arc
React starter kit based on Atomic Design
Stars: ✭ 2,780 (+490.23%)
Mutual labels:  starter-kit, isomorphic, boilerplate
Project Webcube
Continuously updated JS infrastructure for modern web dev
Stars: ✭ 141 (-70.06%)
Mutual labels:  starter-kit, isomorphic, boilerplate
React Redux Styled Hot Universal
react boilerplate used best practices and focus on performance
Stars: ✭ 147 (-68.79%)
Mutual labels:  starter-kit, isomorphic, boilerplate
React Server Example Tsx
⚛️ Boilerplate for isomorphic web app with React server-side rendering in TypeScript
Stars: ✭ 256 (-45.65%)
Mutual labels:  isomorphic, boilerplate
React Starter Kit
React Starter Kit — front-end starter kit using React, Relay, GraphQL, and JAM stack architecture
Stars: ✭ 21,060 (+4371.34%)
Mutual labels:  boilerplate, starter-kit
React Native Navigation Redux Starter Kit
React Native Navigation(v2) Starter Kit with Redux, Saga, ESLint, Babel, Jest and Facebook SDK 😎
Stars: ✭ 271 (-42.46%)
Mutual labels:  starter-kit, boilerplate
Flask Api Starter Kit
Start a Flask API in less than 5 minutes
Stars: ✭ 296 (-37.15%)
Mutual labels:  starter-kit, boilerplate
Angular Ssr
Angular 4+ server-side rendering solution compatible with @angular/material, jQuery, and other libraries that touch the DOM (as well as providing a rich feature set!)
Stars: ✭ 283 (-39.92%)
Mutual labels:  isomorphic, server-rendering
Project Stub
deps
Stars: ✭ 300 (-36.31%)
Mutual labels:  starter-kit, boilerplate
Electron React Boilerplate
A Foundation for Scalable Cross-Platform Apps
Stars: ✭ 18,727 (+3876.01%)
Mutual labels:  starter-kit, boilerplate
isomorphic-relay-boilerplate
No description or website provided.
Stars: ✭ 30 (-93.63%)
Mutual labels:  isomorphic, starter-kit
fastify-vite
This plugin lets you load a Vite client application and set it up for Server-Side Rendering (SSR) with Fastify.
Stars: ✭ 497 (+5.52%)
Mutual labels:  isomorphic, server-rendering
Scalable React Boilerplate
⭐️ Scalable feature-first React micro-framework made for Udacity Alumni collaborative projects
Stars: ✭ 260 (-44.8%)
Mutual labels:  isomorphic, boilerplate
universal-react-relay-starter-kit
A starter kit for React in combination with Relay including a GraphQL server, server side rendering, code splitting, i18n, SEO.
Stars: ✭ 14 (-97.03%)
Mutual labels:  isomorphic, starter-kit
Whitestorm Typescript Boilerplate
📦 🚀 TypeScript boilerplate for WhitestormJS using react/redux ⚛
Stars: ✭ 285 (-39.49%)
Mutual labels:  starter-kit, boilerplate
Graphql Starter
💥 Monorepo template (seed project) pre-configured with GraphQL API, PostgreSQL, React, Relay, and Material UI.
Stars: ✭ 3,377 (+616.99%)
Mutual labels:  starter-kit, boilerplate
Nodejsstarterkit
Starter Kit for Node.js v14.x, minimum dependencies 🚀
Stars: ✭ 348 (-26.11%)
Mutual labels:  starter-kit, boilerplate
Go Api Boilerplate
Go Server/API boilerplate using best practices DDD CQRS ES gRPC
Stars: ✭ 373 (-20.81%)
Mutual labels:  starter-kit, boilerplate
React Firebase Admin
React ⚛️ starter kit with Firebase 🔥 and Bulma for setting up an admin dashboard - Highly scalable, PWA, Serverless
Stars: ✭ 232 (-50.74%)
Mutual labels:  starter-kit, boilerplate

Build Status

Universal Redux Template

A boilerplate doing universal/isomorphic rendering with Redux + React-router + Express, based on Redux-Realword-Example

Philosophy

To bootstrap a React app development environment is not an easy task, there are so many libraries to setup, including webpack, babel, testing stuff and others. I'd like this boilerplate to be a ready-to-use one with the essential tools and the simplest logic that just work to build a universal rendering React + Redux app. That's why there is no fancy stuff in this app, since it's a basis of your killer app rather than a showcase one.

How to use this template?

  • clone this app and name it as whatever your want: $ git clone https://github.com/mz026/universal-redux-template.git my-killer-app

  • remove the .git folder since you won't need the history of this boilerplate: $ cd my-killer-app; rm -rf .git

  • start out a new git history: $ git init

  • Install dependencies: $ yarn install

  • Host dev environment and start to build something changing the world! $ yarn start

  • To run the test with Mocha, Enzyme, Sinon and Chai: $ yarn test:ci

  • To generate a container/component/action and its tests: $ ./bin/generate <type> <path>

eg: $ ./bin/generate component myNamespace/MyComponent

Features:

  • Universal rendering, with async data support
  • Server side redirect
  • Separate vendor and app js files
  • Use Immutable as store data
  • Hot Reload on client side by Webpack
  • Hot Reload on server side (ref)

Stack:

Testing:

Tools:

Development process:

When developing a feature,

  • First run a separate process converting ES6 to ES5 lively:
$ yarn run test:watch
  • Run the test case of a single file/directory by:
$ yarn test -- <the-file-path>

For example:

$ yarn test -- app/test/actions
  • Before deployment, run all the test cases to make sure everything is fine by:
$ yarn test:ci

Why

The way suggested by babel's doc compiles the code on the fly, which is too slow, especially when the number of files grows:

//package.json

{
  "scripts": {
    "test": "mocha --compilers js:babel-register"
  }
}

So here we pre-compile the code, watch it, and maintain a cache to avoid repeated build of the files that doesn't change. After the pre-compile, the testing cycle can be much faster than before, especially when doing TDD.

For Winners Vimmers:

For vim users, there's a plugin called vim-test binding tests with the editor. You can trigger a test "nearest the cursor", which is super handy when doing TDD.

To make vim-test work together with the pre-compile process,

  1. copy the editor_configs/vimrc to <project-root>/.vimrc
  2. make sure these two lines exist in your ~/.vimrc to enable directory-based .vimrc:
set exrc
set secure

Then you can enjoy the fast feedback loop powered by the greatest editor on the planet.

Routes Draft:

  • Intro page: {base_url}
  • Questions Page: {base_url}/questions
  • Question Detail Page: {base_url}/questions/:id

How it works:

Assets Management

When handling static assets, we want to achieve the following goals:

  • Make assigning assets url a no-brainer
  • Apply revision when deploying to production to integrate with CDN services easily

The usage example can be found in [Intro Container](https://github.com/mz026/universal-redux-template/blob/master/app/containers/Intro.js)

We achieve this by:

First, creating an assets container folder: app/assets

In development mode:

Assign static folder linking /assets to the folder above

In production mode:

Use a gulp task (gulp build) to handle it:

  • A set of [rev](https://github.com/smysnk/gulp-rev-all)-ed assets with hash code appended would be built into dist/public/assets
  • A static middleware mapping root url to the folder mentioned above is configured in server.js
  • A set of [revReplace](https://github.com/jamesknelson/gulp-rev-replace)-ed server code would be built into dist/server-build, so that the rev-ed assets can be used when doing server rendering

Redirect after API Calls

Under some cases, we'd like to do 302 redirect after fetching API. For example:

When users try to access a question page via an unexisting Id, redirect her to Index route.

In the code layer, we want the implementation to be shared on both client and server side. This is achieved by passing a history instance to action creators, and use history.push whenever needed.

On the client side, react-router would then take care the rest of redirecting logic, while on server side, we subscribe the url-chaning events on each request, and redirect requests to proper pages if needed.

Such implementation can be found in QuestionContainer, questions action

Vendor Scripts:

Vendor related scripts are bundled into a vendor.js, associated settings can be found in the entry field of webpack.config.js.

(thanks @dlombardi for pointing it out!)

For Windows Users:

yarn test:

The single quotes in yarn test script surrounding path do not work on Windows, while they're necessary on unix-like machines. Please remove them in scripts.test section in package.json like this:

"test": "NODE_ENV=test NODE_PATH=./app mocha --compilers js:babel-register -r app/spec/support/setup.mocha.js --recursive app/spec/**/*.test.js -w"

(thanks @jbuffin for pointing it out!)

Deployment:

To deploy this app to production environment:

  • Prepare a server with NodeJS environment

  • Use whatever tool to upload this app to server. (Capistrano is a good choice.)

  • Run $ NODE_ENV=production yarn install on server

    • After the installation above, postinstall script will run automatically, building front-end related assets and rev-ed server code under dist/ folder.
  • Kick off the server with:

NODE_ENV=production NODE_PATH=./dist/server-build node dist/server-build/server

Deploy to Heroku

To deploy this app to heroku,

  • Set up heroku git remote url
  • Set API_BASE_URL to heroku config var. (without trailing slash)

Here's a sample deployed to heroku: https://redux-template-test.herokuapp.com/ For this case, the API_BASE_URL mention above would be https://redux-template-test.herokuapp.com

Resources:

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].