In this episode, we walk through the process of setting up the server side of a Laravel application to use Inertia.js. Starting with a fresh Laravel install, we tweak our database credentials and run migrations. Then, it's time to pull in the Inertia Laravel package using Composer.
Once that's done, we look at the default Laravel welcome page and quickly wipe it out so we can replace it with our Inertia-powered setup. We delete the old Blade view and create a new app.blade.php
layout, adding some basic HTML and the Inertia directive, which is where all our Inertia-managed frontend components will get injected.
Next up, we generate and configure the Inertia middleware (HandleInertiaRequests
). We do a quick walk-through of key parts of this file—including settings for the root view (pointing to our new layout), asset versioning to handle updates after deployments, and the handy share()
method for passing global data to all Inertia pages.
We register the middleware in Laravel's HTTP kernel, making sure everything's wired up correctly on the server side. Then, we show how to render an Inertia page from a route using the Inertia helper, prepping for the frontend we'll build later. We also set up a sample Vue component in the right place (even though we haven't hooked up Vue just yet), and show the workflow for compiling frontend assets.
By the end, everything's ready on the backend for us to move onto the client side. In the next episode, we'll tackle the frontend setup—and finally bring our pages to life!