11# React-Router-Vite-Rails
22
3- This is an example web application that proposes a way to integrate React Router Framework/SPA mode and Ruby on Rails.
3+ This is an example web application that proposes a way to integrate React Router Framework/SPA mode with Ruby on Rails.
44
55Consider using the methods in this example
6- to explore a simple way to create a better React SPA integration for Ruby on Rails.
6+ to explore a simple way to create a better React SPA – Rails integration .
77
8- [ Jump to how to build it] ( #how-it-is-built )
9- [ See this example app deployed using Kamal] ( https://rrrails.castle104.com )
8+ - [ Jump to read how to build it] ( #how-it-is-built )
9+ - [ See this example app deployed using Kamal] ( https://rrrails.castle104.com )
1010
1111## The problem
1212
@@ -59,8 +59,8 @@ Note that you can use Next.js [with static exports](https://nextjs.org/docs/app/
5959to generate files that can be statically hosted as an SPA.
6060You could put these on a Ruby on Rails ` public ` folder to achieve simplicity that is similar to the current approach.
6161However, Next.js static exports have difficulties, particularly with dynamic routes,
62- which make it a less straightforward than React Router v7 in SPA mode.
63- Hence, my choice of React Router v7 instead .
62+ which make it less straightforward than React Router v7 in SPA mode.
63+ Hence, my choice of React Router v7 for this example .
6464
6565## Building the Integration
6666
@@ -72,7 +72,7 @@ The step-by-step setup is as follows.
7272### Install Ruby on Rails
7373
7474Just run ` rails new ` to set up the Ruby on Rails server.
75- The default, no-build setup will suffice since Rails is not responsible for building the React application.
75+ The default, no-build setup will suffice since Rails is not responsible for building the React Router application.
7676If you want, you can use [ jsbundling] ( https://github.com/rails/jsbundling-rails ) for additional JavaScript.
7777Note that the React Router app will be completely independent of jsbundling.
7878
@@ -149,12 +149,14 @@ To understand the benefits of using an SPA framework, I believe that you need to
149149
150150### Authentication
151151
152- Running React as a static asset on a Ruby on Rails application makes authentication simple. To illustrate this,
152+ Running React as a static asset on a Ruby on Rails application makes it possible to share cookies,
153+ and this greatly simplifies authentication.
154+ To illustrate this,
153155I have created a simple session-based authentication system in Rails and have used it from the React application.
154156
155157Note that the ERB and the React pages will share authentication.
156- This makes it particularly easy to mix React and ERB pages in the same application
157- if you are gradually transitioning from a React-based site to Hotwire, for example.
158+ This makes it particularly easy to mix React and ERB pages in the same application.
159+ This helps a lot if you are gradually transitioning from a React-based site to Hotwire, for example.
158160
159161### CSRF protection
160162
0 commit comments