Overview
React on Rails is a framework focused on integrating Ruby on Rails with React, particularly for React Server-Side Rendering in order to enhance SEO and performance. The project is maintained by ShakaCode and offers seamless integration with shakapacker for improved efficiency and ease of use.
Features
- Automatic Bundle Configuration: Faster browser loading time through smaller bundle sizes based on React components present on the page.
- React 18 Support: Stay updated with the latest changes in React versions.
- Direct Props Passing: Easily pass props from Rails views to React components, reducing the need for additional API requests.
- Tight Shakapacker Integration: Ensures smooth integration with shakapacker for optimized performance.
- Server-Side Rendering (SSR): Improved SEO indexing and UX performance with SSR capability.
- Automated Entry-point Creation: Streamlined creation of entry-points and bundle inclusion when adding components to a page.
Installation
To integrate React on Rails into your project, follow these steps:
- Add the gem to your Gemfile:
gem 'react_on_rails' - Install the gem by running:
bundle install - Run the generator to set up the necessary files:
rails generate react_on_rails:install - Start the webpacker-dev-server to compile assets:
bin/webpack-dev-server - Finally, start your Rails server:
rails s
Summary
React on Rails provides a powerful framework for seamlessly integrating Ruby on Rails with React, offering features like automatic bundle configuration, React 18 support, direct props passing, SSR capabilities, and more. By combining the strengths of React with the efficiency of shakapacker, React on Rails aims to enhance performance, SEO, and user experience for web applications.