--- id: inertia-rails/skills/inertia-rails-architecture version: "4d7fcce9" license: MIT install: manual updated: 2026-02-13 --- # inertia-rails-architecture — Master the server-driven mental model behind Inertia Rails: the server owns routing, data, and auth while React renders UI only. This skill routes you to the right pattern for pages, forms, navigation, and data refresh through a decision matrix covering data sources, state ownership, and common anti-patterns to avoid. Publisher: inertia-rails · Stars: 64 · Updated: 2026-02-13 Install (manual): `git clone https://github.com/inertia-rails/skills` ## SKILL.md # Inertia Rails Architecture Server-driven architecture for Rails + Inertia.js + React when building pages, forms, navigation, or data refresh. Inertia is NOT a traditional SPA — the server owns routing, data, and auth. React handles rendering only. ## The Core Mental Model The server is the source of truth. React receives data as props and renders UI. There is no client-side router, no global state store, no API layer. **Before building any feature, ask:** - **Where does the data come from?** → If server: controller prop. If user interaction: `useState`. - **Who owns this state?** → If it's in the URL or DB: server owns it (use props). If it's ephemeral UI: React owns it. - **Am I reaching for a React/SPA pattern?** → Check the decision matrix below first — Inertia likely has a server-driven equivalent. ## Decision Matrix | Need | Solution | NOT This | |------|----------|----------| | Page data from server | Controller props | useEffect + fetch | | Global data (auth, config) | `inertia_share` + `usePage()` | React Context / Redux | | Flash messages / toasts | Rails `flash` + `usePage().flash` | inertia_share / React state | | Form submission | `