Giter Site home page Giter Site logo

sadafk831 / universal-redux Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bdefore/universal-redux

0.0 2.0 0.0 3.95 MB

An npm package that lets you jump right into coding React and Redux, with universal (isomorphic) rendering and without having to manage or maintain Express setups or Webpack configurations.

License: MIT License

JavaScript 95.68% Shell 4.32%

universal-redux's Introduction

Universal Redux

npm version build status Dependency Status devDependency Status Demo on Heroku

With the default configuration, Universal Redux provides routing with React Router as well as a hot-reloading development server. Fonts and styles (SASS, Less, CSS) are also ready to go.

There is an example project which is continuously deployed on Heroku.

Usage

  • Install
npm install universal-redux
  • Add a configuration file in your project at config/universal-redux.config.js that defines what properties you want to customize. You can start by copying the annotated example.

  • Specify your build steps

The following npm bin aliases have been defined:

universal-redux-dev
universal-redux-watch
universal-redux-server
universal-redux-build

You'll generally call these from the corresponding section of your project's scripts. See package.json in the example project.

  • Create a routes file

Generally kept in src/routes.js, this is where you define what routes map to what views. See routes.js in the example project.

  • Make some code!

Customization

The npm module also exposes a few ways of integrating your code with that of the module.

Webpack configuration

Any items specified in the webpack.config of your configuration will be merged with the default Webpack configuration. You may also turn on verbose mode to see the exact Webpack configuration you are running.

Express middleware

You can add your own Express middleware like so:

import universal from 'universal-redux';
import config from '../config/universal-redux.config.js';

const app = universal.app();

// add some middleware
// add some more middleware

universal.setup(config);
universal.start();

Alternatively, you may pass your own Express instance as a parameter when calling universal.app().

Redux middleware

You can activate your own Redux middleware by specifying the middleware property in the configuration file. This must be a path to a file which exports each middleware as a function. On serverside renders, those functions will be called with two parameters: the Express request and response objects. On clientside renders, they will be called with none. All properties specified in globals will be available to the middleware.

Replacing the HTML shell

You can specify htmlShell: '/path/to/your/Html.js' in your configuration and this will be used instead of the default one. This allows you to add your own additions to <head> as well as third party <script> tags such as for metrics tracking.

Webpack Isomorphic Tools configuration

You can add or override the default webpack-isomorphic-tools configuration, by providing a toolsConfigPath value to your config.js.

Local development

If you'd like to develop on Universal Redux, clone the repo and while testing with a project that uses it, you can run PROJECT_PATH=/path/to/project npm run dev from the Universal Redux root, which will watch for changes and copy them over to your project's node_modules/universal-redux/lib directory. If any of your changes add dependencies, you will need to copy those over manually.

Todo

  • Pass in your own Express app instance
  • Configurable custom Redux middleware
  • Review dependencies, move applicable ones to devDependencies
  • Review adding additional peerDependencies
  • Example with JWT authentication
  • Finalize API before 1.0
  • Branch for redux-simple-router rather than redux-router
  • Built-in page transitions

Inspirations

This project forked off of react-redux-universal-hot-example. Please refer to the README there for more details and join the discussion at the pull request.

universal-redux's People

Contributors

erikras avatar bdefore avatar greenkeeperio-bot avatar stevoland avatar leonli avatar korczis avatar justingreenberg avatar quicksnap avatar nicolabortignon avatar catamphetamine avatar swordsreversed avatar benoitvallon avatar mhodgson avatar trueter avatar gaearon avatar arkist avatar markus-ipse avatar nogsmpls avatar snowcxt avatar standuprey avatar lemoncms avatar b2whats avatar istravis avatar msikma avatar yuters avatar guilhermesad avatar austinpray avatar ashtonsix avatar alexanderchan avatar maxcnunes avatar

Watchers

James Cloos avatar Sadaf Khan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.