Introduction to Using React with Rails

Read about how we'll use React with Rails in this chapter.

React has emerged as probably the most popular of the current JavaScript frameworks. It has a huge user base and a large ecosystem. Structurally, React is the polar opposite of Stimulus. It’s more complex, and as you’ll see, its design reflects fundamentally different assumptions about how to manage state and logic in a JavaScript program.

For our purposes in this course, we will only use a fraction of React’s capabilities; our focus here will be on using React to support interactivity on a single page while working with our Rails application. We will not focus on using React for a single-page application (SPA). An SPA is a perfectly reasonable thing to write, but it is more complex and less likely to benefit from Rails. We’re going to show simpler use cases.

With that being said, there are many, many opinions on how to write and structure React apps, and I’m not going to make an attempt to catalog them all here. This is one way to write React applications for Rails, but it’s not meant to be the way.

Get hands-on with 1200+ tech skills courses.