In this episode, we're fixing the annoying issue that we can't sign out of our app! We'll add a proper logout feature to the navigation.
Here's what we do: First, we look at our app's routes and confirm there's a logout
route already set up — nice! Next, we work on the sign out link in the navigation; since logout needs to be a POST request, we can't just use a simple link. So, we swap the link for a button and set up a click handler for it.
Inside the handler, we use Inertia's router to send a POST request to the logout route by its name. We also tweak the button's styling, so it still looks like a link and fits into the nav cleanly.
Finally, we test everything out. Click the button, and boom — we're signed out and redirected as expected! We also double-check that signing back in works smoothly. Now, the app has an actual log out function, making things way easier for users.