IslandJS Rails supports the development of React (or other JS library) islands in Rails apps by synchronizing package.json defined dependencies with UMD libraries served in public/islands/vendor.
Write Turbo compatible JSX in app/javascript/islands/components/ and render it with a react_component helper in ERB templates (including Turbo Stream partials) — Vue and other framework support can be added with a bit of work.
💡 Turbo Cache Compatible: React components automatically persist state across Turbo navigation! See Turbo Cache Integration for details.
Every React component should be written to accept a single containerId prop and rendered using the react_component view helper, which accepts a JSON object of props.
The props data passed into react_component is automatically available via useTurboProps and can be optionally cached using useTurboCache for persistence across Turbo navigation.
Do not pass sensitive data to the client-side via props. Pass it any other (secure) way — props are encoded in the HTML and are visible to the client and any other scripts.