Installation Overview

Here's an overview of installation if you're not using the generator.

Note, the best way to understand how to use ReactOnRails is to study the examples:

  1. spec/dummy: Simple, no DB example.
  2. github.com/shakacode/react-webpack-rails-tutorial: Full featured example.

Configure the /client Directory

This directory has no references to Rails outside of the destination directory for the files created by the various Webpack config files.

The only requirements within this directory for basic React on Rails integration are:

  1. Your webpack configuration files:
    1. Create outputs in a directory like /app/assets/webpack, which is customizable in your config/initializers/react_on_rails.rb.
    2. Provide server rendering if you wish to use that feature.
  2. Your JavaScript code "registers" any components and stores per the ReactOnRails APIs of ReactOnRails.register(components) and ReactOnRails.registerStore(stores). See API docs in README.md and the ReactOnRails.js source.
  3. Set your registration file as an "entry" point in your Webpack configs.
  4. You create scripts in client/package.json per the example apps. These are used for building your Webpack assets. Also do this for your top level package.json.

Rails Steps (outside of /client)

  1. Configure the config/initializers/react_on_rails.rb. You can adjust some necessary settings and defaults. See file spec/dummy/config/initializers/react_on_rails.rb for a detailed example of configuration, including comments on the different values to configure.
  2. Configure your Procfiles per the example apps. These are at the root of your Rails installation.
  3. Configure config/initializers/assets.rb probably like spec/dummy/config/initializers/assets.rb. This example shows what's necessary if you're enabling the hot-reloading Rails development option.
  4. Configure your top level JavaScript files for inclusion in your layout. You'll want a version that you use for static assets, and you want a file for any files in your setup that are not part of your webpack build. The reason for this is for use with hot-reloading. If you are not using hot reloading, then you only need to configure your application.js file to include your Webpack generated files. For more information on hot reloading, see Hot Reloading of Assets For Rails Development

  5. Configure your lib/tasks/assets.rake file to run webpack during asset precompilation.

  6. If you are deploying to Heroku, see heroku-deployment.md

If I missed anything, please submit a PR or file an issue.

results matching ""

    No results matching ""