In this episode, we dive into shorthand routes with Inertia. Sometimes you just want to set up a simple page—like an About page for your app—without having to go through the hassle of creating a dedicated controller. We walk through how to add a new About
page by just making a Vue component, copying over a template, and updating it for our needs.
Instead of registering this page the "normal" controller way, we use Inertia’s route::inertia()
function. This lets you directly specify the URL and which Vue component to render, all from your routes file. We talk about when this approach makes sense—mainly for static pages that don’t need to pull in lots of dynamic data.
But, sometimes you do want to pass a little bit of information down, like the app’s name. We cover how you can pass a tiny amount of props (like from your config) as a third argument to these shorthand routes. The big advice here: keep it simple! Don’t pass a bunch of data or load up your routes file with complicated logic—that still belongs in a controller.
By the end, you’ll see how handy shorthand routes can be for quickly setting up basic pages while keeping your codebase neat and tidy.