whatisgithub

What is react-rails?

reactjs/react-rails — explained in plain English

Analysis updated 2026-06-24

6,758JavaScriptAudience · developerComplexity · 3/5Setup · moderate

In one sentence

A Ruby gem that connects React components to Ruby on Rails apps, letting you render React from Rails views with server-side HTML generation for fast initial loads and browser-side interactivity.

Mindmap

mindmap
  root((react-rails))
    What It Does
      React in Rails views
      Server-side rendering
      Client-side hydration
    Asset Bundling
      Shakapacker webpack
      Sprockets pipeline
    Features
      View helper
      Component generator
      SSR configuration
    Migration Path
      react on rails gem
      Active development
      TypeScript internals
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Render React components from Rails view templates using a simple view helper without manually configuring a build pipeline.

USE CASE 2

Add server-side rendering to a Rails app so React components generate HTML on the server before JavaScript loads.

USE CASE 3

Write React components in JSX or TypeScript inside a Rails project using Shakapacker for asset bundling.

What is it built with?

RubyRailsReactJavaScriptJSXTypeScriptWebpack

How does it compare?

reactjs/react-railsbrunch/brunchthebird/swipe
Stars6,7586,7586,755
LanguageJavaScriptJavaScriptJavaScript
Setup difficultymoderateeasyeasy
Complexity3/52/51/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 1h+

Requires a Rails app with either Shakapacker or Sprockets already configured for JavaScript bundling.

So what is it?

react-rails is a Ruby gem that connects the React JavaScript library with Ruby on Rails web applications. Without this gem, using React in a Rails app requires manual configuration to bundle and serve JavaScript components. This gem handles that integration, letting you render React components directly from Rails views and controllers. The main feature is server-side and client-side rendering. When a page loads, Rails can generate the initial HTML on the server using React components, which means the browser shows content immediately without waiting for JavaScript to run. The same components then become interactive in the browser. This gives you the speed of server-rendered HTML with the interactivity of a React application. To use a React component in a Rails view, you call a view helper that the gem provides, passing the component name and any data it needs. The gem supports writing components in JSX (the syntax most React developers use), as well as TypeScript and CoffeeScript. It works with both Shakapacker, the current webpack-based tool for Rails, and the older Sprockets asset pipeline, so it fits into both newer and older Rails setups. The README notes that ShakaCode, which currently maintains this gem, recommends considering a migration to a separate gem called react_on_rails for new projects. That project receives more active development, has TypeScript internals, and supports newer React features like React Server Components. Migration guides and an AI-assisted migration prompt are included in the repository. The gem includes a generator for creating new component files, configuration options for server-side rendering, and documentation on common errors. It is listed in the reactjs GitHub organization, indicating an association with the official React project, though day-to-day maintenance is handled by the ShakaCode team.

Copy-paste prompts

Prompt 1
Show me how to add a React component to a Rails 7 view using react-rails, passing data from the controller as props.
Prompt 2
How do I enable server-side rendering with react-rails so my React components produce HTML on the server before the JavaScript loads?
Prompt 3
Help me create a new React component file using the react-rails generator and wire it up to a Rails form.
Prompt 4
I am using react-rails with Sprockets, how do I migrate to Shakapacker while keeping my existing components working?
Prompt 5
The react-rails README recommends react_on_rails for new projects. Help me understand the key differences and decide whether to migrate.

Frequently asked questions

What is react-rails?

A Ruby gem that connects React components to Ruby on Rails apps, letting you render React from Rails views with server-side HTML generation for fast initial loads and browser-side interactivity.

What language is react-rails written in?

Mainly JavaScript. The stack also includes Ruby, Rails, React.

How hard is react-rails to set up?

Setup difficulty is rated moderate, with roughly 1h+ to a first successful run.

Who is react-rails for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.