Courses

React.js + Inertia in Laravel 11: From Scratch

Logout and Link with POST Method

Summary of this lesson:
- Implement logout functionality
- Create logout route and controller
- Use Inertia Link with POST method
- Handle user session termination
- Implement client-side logout

In this lesson, let's work on the logout functionality. I will show you how to use Inertia to make a link, but with post method.


To perform the logout, first on the back-end, let's create the route.

routes/web.php:

Route::view('/', 'dashboard')->name('dashboard');
 
Route::middleware('auth')->group(function () {
Route::resource('posts', PostController::class);
Route::inertia('about', 'About')->name('about');
Route::post('logout', [\App\Http\Controllers\Auth\LoginController::class, 'destroy'])->name('logout');
});
Route::inertia('login', 'Auth/Login')->name('login');
Route::post('login', [\App\Http\Controllers\Auth\LoginController::class, 'store'])->name('login.post');

In the Controller, we will use...

The full lesson is only for Premium Members.
Want to access all 18 lessons of this course? (57 min read)

You also get:

  • 69 courses (majority in latest Laravel 11)
  • Premium tutorials
  • Access to repositories
  • Private Discord