Responses
Creating Responses
Creating an Inertia response is simple. To get started, invoke the Inertia::render() method within your controller or route, providing both the name of the JavaScript page component that you wish to render, as well as any props (data) for the page.
In the example below, we will pass a single prop (event) which contains four attributes (id, title, start_date and description) to the Event/Show page component.
using InertiaCore;
public class EventsController : Controller{ public IActionResult Show(int id) { var evt = _context.Events.Find(id);
return Inertia.Render("Event/Show", new { Event = new { evt.Id, evt.Title, evt.StartDate, evt.Description, }, }); }}use Inertia\Inertia;
class EventsController extends Controller{ public function show(Event $event) { return Inertia::render('Event/Show', [ 'event' => $event->only( 'id', 'title', 'start_date', 'description' ), ]);
// Alternatively, you can use the inertia() helper... return inertia('Event/Show', [ 'event' => $event->only( 'id', 'title', 'start_date', 'description' ), ]); }}<meta name="twitter:title" content="@Model.Props["event"].Title"><meta name="twitter:title" content="{{ $page['props']['event']->title }}">return Inertia.Render("Event", new { Event = evt }) .WithViewData(new Dictionary<string, object> { ["meta"] = evt.Meta });return Inertia::render('Event', ['event' => $event]) ->withViewData(['meta' => $event->meta]);<meta name="description" content="@ViewData["meta"]"><meta name="description" content="{{ $meta }}">