In this episode, we work on building out our dashboard page and take a look at how routing works in a Laravel + Inertia.js app. We start by creating a controller and route for our dashboard, getting it all set up to render a new page. After wiring things up, we talk about a best practice: referencing routes by their name instead of hardcoding URLs directly. This saves a ton of headaches later if your URLs ever change!
That’s where Ziggy comes in. If you haven't used Ziggy before, it's a super handy package that lets you use your Laravel named routes directly in your JavaScript code. We walk through installing Ziggy on both the backend (composer) and frontend (npm/yarn), and see how it exposes your route definitions for use on the client.
We also go over how to inject your route data into the frontend safely and point out how you can control which routes are exposed for security. Once that's set up, you get a nice route()
helper in JavaScript, which lets us update all navigation links to use route names instead of URLs. We update both the desktop and mobile navigation bars, making sure everything's neat and futureproof.
Finally, we show that everything works by clicking around and confirming that navigation now runs through named routes on the client side—no more URL headaches if anything changes. By the end of the episode, Ziggy is up and running and your app is set for more maintainable navigation!