Reference tutorial app for React on Rails with SSR, Fast Refresh HMR, and Shakapacker/Webpack.
94
stars
87
commits
Ruby
primary language
Sep 3, 2026
updated
Each commit demonstrates a step in the React on Rails Tutorial.
UPDATE July 2, 2024: This repo is updated to the latest shakapacker gem and package v8.0.0 and React on Rails v14.0.3 releases!
Please ⭐️ this repo if you find this useful.
See the commit history.
shakpacker v8! (see explanation of the switch at rails/webpacker).git clone git@github.com:shakacode/react_on_rails_demo_ssr_hmr.git
corepack yarn install
bin/setup
corepack yarn activates the Yarn 3.2.1 release pinned by this repository's
packageManager field and .yarnrc.yml; bin/setup then prepares the
development database.
Use the provided Procfiles to run webpack and rails together, like overmind start -f Procfile.dev
Procfile.dev: Uses the webpack-dev-server. This will proxy asset requests to the webpack-dev-server except for a few files: the manifest.json and the server-bundle.js which are in the standard public/webpack/development folder.Procfile.dev-static: Uses the standard files in the public/webpack/development folder. Note, the standard webpack config in /config/webpack outputs an array which builds both the client and server bundles.bin/dev
# or
overmind start -f Procfile.dev
bin/dev-static
# or
overmind start -f Procfile.dev-static
Starting from Shakapacker 6.1.1, it is possible to use SWC in projects. See demo-branch-swc-loader branch for a demonstration of SWC usage.
Please check out Shakapacker - Using SWC Loader documentation for more information about this feature.
bin/dev or bin/dev-static (or run Procfile.dev or Procfile.dev-static with your favorit process manager like overmind or foreman).[webpack-dev-server] Hot Module Replacement enabled.app/javascript/bundles/HelloWorld/components/HelloWorld.tsx, like changing some text in the React code, and save the file.
app/javascript/bundles/HelloWorld/components/HelloWorld.module.css and change the color. You will either see an instant update to the webpage with HMR, or you will need to refresh the page.
[webpack-dev-server] App updated. Recompiling...
index.js:519 [webpack-dev-server] App hot update...
log.js:24 [HMR] Checking for updates on the server...
log.js:24 [HMR] Updated modules:
log.js:16 [HMR] - ./app/javascript/bundles/HelloWorld/components/HelloWorld.module.css
log.js:24 [HMR] App is up to date.
RAILS_ENV=production rake assets:precompilerails s -e productionThis repo now includes shared cpflow scaffolding for review apps, automatic
staging deploys from master, and manual production promotion. See
.controlplane/readme.md for the required Control Plane and GitHub setup.
config/webpack/webpack.config.jsNODE_ENV=production RAILS_ENV=production bin/webpacker --debug-webpackerNote, this repo started with rails/webpacker v5 and an older version of React on Rails. These are for example purposes only. They are not a set of tutorial steps if you want to be on the current versions.
Rails new: rails new --skip-sprockets -J --skip-turbolinks test-react-on-rails-v12-ssr-v2
Add webpacker gem: bundle add webpacker
Add React on Rails gem: bundle add react_on_rails.
Set React on Rails version to be exact: Edit the Gemfile and run bundle.
Install webpacker: bundle exec rails webpacker:install
Install webpacker React: bundle exec rails webpacker:install:react
Install React on Rails: rails generate react_on_rails:install
Add HMR and Fast Refresh
Leverages the react-refresh-webpack-plugin to have Fast Refresh working with Webpack v4. Note, ensure HMR is enabled for the dev server: hmr: true in webpacker.yml. After this change, you can:
foreman start -f Procfile.dev-hmrrails/webpacker installs TypeScript into webpack: bundle exec rails webpacker:install:typescript
Convert demo screen and ReactOnRails registration to Typescript
Enable simple Server-Side Rendering (SSR) for Hello World using the same bundle for client and server rendering. This is the simple, but imperfect way to turn on SSR using the same bundle for the server and client. HMR is not available.
Switch to separate bundle for server-side rendering Convert to separate bundles for server vs. client rendering with HMR


This project is sponsored by the software consulting firm ShakaCode. We focus on React front-ends, often with Ruby on Rails or Gatsby, using TypeScript or ReasonML. The best way to see what we do is to see the details of our recent work.
Interested in optimizing your webpack setup for React on Rails including code splitting with react-router, and loadable-components with server-side rendering? We just did this for Popmenu, lowering Heroku costs 20-25% while getting a 73% decrease in average response times.
Feel free to contact Justin Gordon, justin@shakacode.com, maintainer of React on Rails, for more information.
Click to join React + Rails Slack.
ShakaCode is hiring! Check out our open positions.
Ruby
60.2%
JavaScript
15.0%
Shell
9.0%
HTML
8.4%
Dockerfile
3.0%
TypeScript
2.7%
CSS
1.5%
Reference tutorial app for React on Rails with SSR, Fast Refresh HMR, and Shakapacker/Webpack.
94
stars
87
commits
Ruby
primary language
Sep 3, 2026
updated
Each commit demonstrates a step in the React on Rails Tutorial.
UPDATE July 2, 2024: This repo is updated to the latest shakapacker gem and package v8.0.0 and React on Rails v14.0.3 releases!
Please ⭐️ this repo if you find this useful.
See the commit history.
shakpacker v8! (see explanation of the switch at rails/webpacker).git clone git@github.com:shakacode/react_on_rails_demo_ssr_hmr.git
corepack yarn install
bin/setup
corepack yarn activates the Yarn 3.2.1 release pinned by this repository's
packageManager field and .yarnrc.yml; bin/setup then prepares the
development database.
Use the provided Procfiles to run webpack and rails together, like overmind start -f Procfile.dev
Procfile.dev: Uses the webpack-dev-server. This will proxy asset requests to the webpack-dev-server except for a few files: the manifest.json and the server-bundle.js which are in the standard public/webpack/development folder.Procfile.dev-static: Uses the standard files in the public/webpack/development folder. Note, the standard webpack config in /config/webpack outputs an array which builds both the client and server bundles.bin/dev
# or
overmind start -f Procfile.dev
bin/dev-static
# or
overmind start -f Procfile.dev-static
Starting from Shakapacker 6.1.1, it is possible to use SWC in projects. See demo-branch-swc-loader branch for a demonstration of SWC usage.
Please check out Shakapacker - Using SWC Loader documentation for more information about this feature.
bin/dev or bin/dev-static (or run Procfile.dev or Procfile.dev-static with your favorit process manager like overmind or foreman).[webpack-dev-server] Hot Module Replacement enabled.app/javascript/bundles/HelloWorld/components/HelloWorld.tsx, like changing some text in the React code, and save the file.
app/javascript/bundles/HelloWorld/components/HelloWorld.module.css and change the color. You will either see an instant update to the webpage with HMR, or you will need to refresh the page.
[webpack-dev-server] App updated. Recompiling...
index.js:519 [webpack-dev-server] App hot update...
log.js:24 [HMR] Checking for updates on the server...
log.js:24 [HMR] Updated modules:
log.js:16 [HMR] - ./app/javascript/bundles/HelloWorld/components/HelloWorld.module.css
log.js:24 [HMR] App is up to date.
RAILS_ENV=production rake assets:precompilerails s -e productionThis repo now includes shared cpflow scaffolding for review apps, automatic
staging deploys from master, and manual production promotion. See
.controlplane/readme.md for the required Control Plane and GitHub setup.
config/webpack/webpack.config.jsNODE_ENV=production RAILS_ENV=production bin/webpacker --debug-webpackerNote, this repo started with rails/webpacker v5 and an older version of React on Rails. These are for example purposes only. They are not a set of tutorial steps if you want to be on the current versions.
Rails new: rails new --skip-sprockets -J --skip-turbolinks test-react-on-rails-v12-ssr-v2
Add webpacker gem: bundle add webpacker
Add React on Rails gem: bundle add react_on_rails.
Set React on Rails version to be exact: Edit the Gemfile and run bundle.
Install webpacker: bundle exec rails webpacker:install
Install webpacker React: bundle exec rails webpacker:install:react
Install React on Rails: rails generate react_on_rails:install
Add HMR and Fast Refresh
Leverages the react-refresh-webpack-plugin to have Fast Refresh working with Webpack v4. Note, ensure HMR is enabled for the dev server: hmr: true in webpacker.yml. After this change, you can:
foreman start -f Procfile.dev-hmrrails/webpacker installs TypeScript into webpack: bundle exec rails webpacker:install:typescript
Convert demo screen and ReactOnRails registration to Typescript
Enable simple Server-Side Rendering (SSR) for Hello World using the same bundle for client and server rendering. This is the simple, but imperfect way to turn on SSR using the same bundle for the server and client. HMR is not available.
Switch to separate bundle for server-side rendering Convert to separate bundles for server vs. client rendering with HMR


This project is sponsored by the software consulting firm ShakaCode. We focus on React front-ends, often with Ruby on Rails or Gatsby, using TypeScript or ReasonML. The best way to see what we do is to see the details of our recent work.
Interested in optimizing your webpack setup for React on Rails including code splitting with react-router, and loadable-components with server-side rendering? We just did this for Popmenu, lowering Heroku costs 20-25% while getting a 73% decrease in average response times.
Feel free to contact Justin Gordon, justin@shakacode.com, maintainer of React on Rails, for more information.
Click to join React + Rails Slack.
ShakaCode is hiring! Check out our open positions.
Ruby
60.2%
JavaScript
15.0%
Shell
9.0%
HTML
8.4%
Dockerfile
3.0%
TypeScript
2.7%
CSS
1.5%