Introducing a new way to review your PRs.

Read the announcement

shakacode / react-webpack-rails-tutorial

Legacy full-app React on Rails tutorial repo and live demo. See reactonrails.com/examples for current maintained demos.

View on GitHub

16 documents · Updated Nov 4, 2026

overview

Knowledge Base updated: 2026-11-03

React Webpack Rails Tutorial Knowledge Base

Orientation

This repository is a Rails tutorial application that compares several React delivery and comment-management approaches: JavaScript React, Hotwire, ReScript, server rendering, and React Server Components.

Rails owns routes, persistence, HTML/JSON endpoints, Action Cable, jobs, layouts, and page templates. Frontend code is built through Shakapacker/Rspack into browser, Node-renderer, and RSC-oriented bundles.

Comment state is persisted by Rails and exposed through server endpoints; browser clients render and mutate it through their respective implementations. Development orchestration coordinates Rails, asset watchers, ReScript, Node rendering, and Redis.

System architecture

flowchart LR
  Browser[Browser]
  Rails[Rails application]
  Routes[Routes and page templates]
  Comments[Comments controller and model]
  Cable[Action Cable channel]
  Jobs[Broadcast job]
  Redis[Redis]
  JS[JavaScript React UI]
  Hotwire[Turbo and Stimulus UI]
  ReScript[ReScript comment UI]
  RSC[React Server Components]
  RoR[React on Rails integration]
  Node[Node renderer]
  Build[Shakapacker and Rspack]
  Assets[Generated client/server packs]

  Browser --> Rails
  Rails --> Routes
  Rails --> Comments
  Comments --> Jobs
  Jobs --> Cable
  Cable --> Redis
  Redis --> Browser
  Browser --> JS
  Browser --> Hotwire
  Browser --> ReScript
  Browser --> RSC
  Rails --> RoR
  RoR --> Node
  Build --> Assets
  Assets --> Browser
  Assets --> Node

Glossary

  • React on Rails: the Rails integration layer that registers React components and renders them from Rails views.
  • Shakapacker: the Rails-facing asset-pack integration used to serve built frontend bundles.
  • Rspack: the JavaScript bundler configuration used for the tutorial's frontend targets.
  • RSC: React Server Components, demonstrated through a dedicated server/client component and bundle path.
  • ReScript bridge: generated JavaScript-facing component bindings that let Rails-delivered frontend code use ReScript UI components.

Codebase-wide invariants

  • Rails remains the source of truth for comment persistence and HTTP response handling; evidence: app/…/comment.rb and app/…/comments_controller.rb.
  • Every frontend delivery mode is exposed through Rails routes and page templates; evidence: config/routes.rb and app/views/**.
  • Browser-facing packs must be produced by the configured asset pipeline before Rails can serve their current output; evidence: package.json and config/**/shakapacker*.
  • ReScript test execution depends on its generated/build artifacts being current; evidence: package.json and spec/…/rescript_spec.rb.
  • Realtime comment delivery passes through Rails jobs and Action Cable rather than direct client-to-client messaging; evidence: app/jobs/** and app/channels/**.

Routing table