Implementing Authentication in Laravel 8/9 using Tailwind UI

Implementing authentication in Laravel is very easy and simple. Almost everything is already configured for use. The authentication file is located at config/auth.php. This file contains various well documented options for customizing the functionality of the authentication services.

In this tutorial, we will show you how to build a Laravel application from scratch and implement built-in authentication for user registration and login with a beautiful modern UI powered by Tailwind.

Laravel offers authentication and application starter kits. These kits scaffold your app with the routes, controllers, and views you'll need to register and authenticate your users.

Laravel Jetstream is a beautifully designed Laravel application starter kit that provides the implementation for user's Login, registration, email verification, two-factor authentication, session management, API via Laravel Sanctum, and optional team management features.

Jetstream is built with Tailwind CSS and supports Livewire or Inertia scaffolding options.

Installation of Jetstream should only be done into a new Laravel applications. If you try to install Jetstream into an existing Laravel application, you'll get unexpected results and problems.

Follow the steps below to complete this tutorial:

Create a Laravel Project

Create a Laravel application using Composer. If you do not have Composer already installed, see how to install it here.

Use composer create-project --prefer-dist laravel/laravel command followed by your project name to create a Laravel application:

composer create-project --prefer-dist laravel/laravel sample-app

Set up Built-in Authentication

To implement authentication in Laravel, do the following:

  1. Navigate to the newly created project:
    cd sample-app
  3. Next, install laravel/ui using Composer:
    composer require laravel/ui
  5. Install jetstream using the following commands:
    composer require laravel/jetstream
    php artisan jetstream:install livewire
  7. Install dependencies:
    npm install
  9. Update MySQL Database connection settings in the .env file as shown in the example below:
  11. To migrate user authentication tables into the database using the following command:
    php artisan migrate

Run the Application

To view quick changes on your UI, use the following command on a separate terminal from inside your project root folder:

npm run watch

Next, run the following command to start your application from inside your project root folder:

php artisan serve --port 8000

Now, open http://localhost:8000 on your browser. You should see a page like the following:

Authentication in laravel 8

You can now modify the login and registration page as per your need.