[](https://github.com/kfly8/Mojolicious-Plugin-Inertia/actions) [](https://metacpan.org/release/Mojolicious-Plugin-Inertia) # NAME Mojolicious::Plugin::Inertia - Inertia.js adapter for Mojolicious # SYNOPSIS ```perl # Mojolicious $app->plugin('Inertia' => { version => '1.0.0', # Asset version for cache busting layout => '
' }); # Mojolicious::Lite plugin 'Inertia' => { version => md5_sum($app->home->child('public/assets/manifest.json')->slurp), layout => app->home->child('dist', 'index.html') }; # In your controller sub index { my $c = shift; # Render Inertia page with props $c->inertia('Home', { user => { name => 'John Doe' }, posts => \@posts }); } # With lazy evaluation sub dashboard { my $c = shift; $c->inertia('Dashboard', { # Regular prop user => $c->current_user, # Lazy prop - only evaluated when needed stats => sub { return $c->calculate_expensive_stats; } }); } ``` # DESCRIPTION [Mojolicious::Plugin::Inertia](https://metacpan.org/pod/Mojolicious%3A%3APlugin%3A%3AInertia) is a [Mojolicious](https://metacpan.org/pod/Mojolicious) plugin that provides server-side adapter for [Inertia.js](https://inertiajs.com/), allowing you to build single-page applications without building an API. Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers. It works by intercepting requests and converting the responses to either full page loads or JSON with just the page component name and props. ## Features - Automatic handling of Inertia and standard HTTP requests - Asset versioning for automatic cache busting - Partial reloads to optimize data transfer - Lazy evaluation of props for performance - History encryption support # OPTIONS [Mojolicious::Plugin::Inertia](https://metacpan.org/pod/Mojolicious%3A%3APlugin%3A%3AInertia) supports the following options. ## version ```perl plugin 'Inertia' => {version => '1.0.0'}; ``` **Required**. Asset version string used for cache busting. When the version changes, Inertia will force a full page reload to ensure users get the latest assets. Common approaches: ```perl # Static version version => '1.0.0' # MD5 hash of manifest file version => md5_sum($app->home->child('manifest.json')->slurp) ``` ## layout ```perl plugin 'Inertia' => {layout => 'layouts/inertia.html.ep'}; ``` **Required**. HTML template or template name containing the root element for your JavaScript application. Must include a `<%= $data_page %>` placeholder where the page data will be inserted. Example template: ```