A sandbox application for exploring how Vite can be used to develop & build Rails with React applications.
The app uses the Vite Ruby, which acts as the 'glue' between the React view layer and the Rails view layer.
- Install Node >= 16
- Install Ruby 3.1.1
gem install bundler
brew install postgresql
npm install
bundle install
rails db:seed
Run the following commands to start the app:
rails s
- starts the Rails servernpm start
- starts the Vite dev server
All front-end related code lives under app/frontend.
The apps directory contains client-side React apps, which correspond to the entrypoints.
The components directory contains any React components that may be used in the apps or pages.
The entrypoints directory contains entries to the apps. These are what the Rails views essentially point to, and what Rails renders when a respective route is hit. More info on entrypoints can be found here.
The pages directory contains client-side React pages, which are used in the client-side routing config of the React apps.
For demonstration purposes, there is a mix of Rails routes and React routes. Each Rails route corresponds to a separate React app, which can define its own routing on the client-side.
/
/help
/browse
/help/account-settings