Inertia
Constants
Constructors
Instance methods
Returns a new HTTP handler for this Inertia instance.
Use this handler in your HTTP server middleware stack. It intercepts the responses from your application and updates them to conform the expected Inertia protocol.
inertia = Inertia.new("1.0.0", MyRenderer.new)
server = HTTP::Server.new([
HTTP::ErrorHandler.new,
HTTP::LogHandler.new,
inertia.http_handler,
])
server.bind_tcp("0.0.0.0", 3000)
server.listen
Renders a component and serializes its props
This methods handles both initial page loads and subsequent Inertia navigation requests automatically, rendering the props within the HTML renderer or returning simple JSON.
You can use a NamedTuple, a Hash or any instance that responds to JSON
serialization (to_json).
inertia.render(
context,
component: "Dashboard",
props: {
user: "John",
unread: 3,
},
)
Renders a component with empty props
Uses current HTTP context to write the response.
The asset version is used to detect when frontend assets have changed and force clients to perform a hard refresh.
Ref: https://inertiajs.com/asset-versioning