Skip to main content

Inertia.js Adapter

ยท 2 min read

The inertia-rage gem brings Inertia.js support to Rage. Build modern single-page apps with React, Vue, or Svelte while keeping the server-side logic in Ruby.

Inertia sits between your backend and frontend - no need for a separate JSON API or client-side routing. You render pages from controllers, pass props, and Inertia handles the rest.

Getting Startedโ€‹

rage new my-app -d postgresql
bundle add inertia-rage

Inherit from RageController::Inertia instead of RageController::API:

class PostsController < RageController::Inertia
def index
render inertia: "Posts/Index", props: { posts: current_user.posts }
end
end

Vite Integrationโ€‹

The adapter integrates with Vite out of the box. In development, the Vite dev server launches automatically when you start Rage. In production, assets are prebuilt during deployment. No manual configuration needed.

Prop Typesโ€‹

The adapter supports four specialized prop types to optimize performance:

  • Lazy props: Evaluated on initial load but skipped during partial reloads if not requested
  • Deferred props: Excluded from initial page load, fetched automatically in a follow-up request
  • Optional props: Never evaluated initially; only loaded when explicitly requested by the frontend
  • Once props: Cached client-side after first evaluation
inertia-rage on GitHub