0.0
No release in over 3 years
A Roda plugin providing server-side Inertia.js adapter
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 5.0
~> 2.0
~> 13.0
~> 1.0
~> 2.0

Runtime

~> 3.0
 Project Readme

Inertia.js Roda Adapter

Server-side Inertia.js adapter for Roda.

Installation

Add to your Gemfile:

gem "inertia-roda"

Quick Start

class App < Roda
  plugin :inertia, version: "1.0"

  def inertia_share
    { user: { email: "bobbytables@example.com"} }
  end

  route do |r|
    r.get "dashboard" do
      inertia "Dashboard", props: { name: "Alice" }
    end

    r.post "logout" do
      logout!
      inertia_redirect "/login"
    end
  end
end

The plugin loads Roda's render plugin automatically. Your layout template calls inertia_root to render the root <div> with page data:

views/layout.erb:

<!DOCTYPE html>
<html>
<head>
  <title>My App</title>
  <!-- Your JS and CSS assets go here (see Vite Integration below) -->
</head>
<body>
  <%= inertia_root %>
</body>
</html>

To customize the views path or layout name, load the render plugin yourself:

plugin :render, views: "app/views", layout: "my_layout"

Vite Integration

inertia-roda pairs well with vite_roda for asset management and hot reloading:

plugin :vite
plugin :inertia, version: -> { ViteRuby.digest }

Use the Vite helpers in your layout to load your frontend entrypoint:

<!DOCTYPE html>
<html>
<head>
  <%= vite_client_tag %>
  <%= vite_javascript_tag "application" %>
</head>
<body>
  <%= inertia_root %>
</body>
</html>

API

inertia(component, props: {})

Renders an Inertia response. Returns JSON for Inertia requests, or a full HTML page (via layout) for initial page loads. Shared props from inertia_share are merged in automatically.

inertia_redirect(path, status: nil)

Inertia-aware redirect. For Inertia requests with non-GET methods, defaults to 303 (forcing a GET). External URLs (different host) return a 409 with X-Inertia-Location header. You can override the status:

inertia_redirect "/destination", status: 301

inertia_share

Provide shared props merged into every response:

def inertia_share
  { user: { email: "bobbytables@example.com"} }
end

License

MIT