In this tutorial you will learn about the Laravel 9 React Auth Tutorial with Example and its application with practical example.
In this Laravel 9 React Auth Tutorial with Example Tutorial I will show how to create login, register, logout, forget password, profile and reset password page using React Auth Scaffolding without using laravel 9 make:auth command. React Auth Scaffolding enable us to generate default laravel authentication scaffolding. React Auth Scaffolding includes fully functional login, register, logout, reset password, forget password, email verification, two-factor authentication, session management.
In this laravel 9 React Auth Scaffolding tutorial I will show you how to use React Auth Scaffolding to create auth scaffolding in laravel 9. React Auth Scaffolding will include login, register, reset the password, forget password, email verification, and two-factor authentication blade views and controller file.
Laravel 9 React Auth Tutorial with Example
In this step by step laravel 9 react auth example tutorial we will learn how to implement or generate Auth Scaffolding using laravel ui and react auth. Please follow the instruction given below:
- Install Laravel 9
- Database Configuration
- Install Laravel UI
- Install React Auth Scaffolding
- Install Npm Packages
- Run PHP artisan Migrate
- Run Development Server
Install Laravel 9
First of all we need to create a fresh laravel project, download and install Laravel 9 using the below command
1 |
composer create-project --prefer-dist laravel/laravel LaravelAuth |
Database Configuration
Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.
1 2 3 4 5 6 |
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=db name DB_USERNAME=db user name DB_PASSWORD=db password |
Install Laravel UI
Now, switch the laravel project directory and run the following composer command to install laravel/ui package. Laravel UI is an official library that offers selective or predefined UI components. The laravel/ui package comes with the login and registration scaffolding for React, Vue, jQuery, and Bootstrap layouts. Run the following composer command to install Laravel/UI.
1 |
composer require laravel/ui |
Install React Auth Scaffolding
Use the following artisan command to Install React auth scaffolding.
1 |
php artisan ui react --auth |
Now, you have successfully installed react auth in your laravel 8 project, you can see your resource directory js folder.
Install Npm Packages
Now, you need to install the bootstrap package and the related frontend dependencies such as jquery from npm using the following command:
1 |
npm install |
Then type the following command on cmd to run npm:
1 |
npm run dev |
Run php artisan Migrate
Now, in this step we will create model and migration file. Please run the following command:
1 |
php artisan migrate |
Run Development Server
Now we are ready to run our example so lets start the development server using following artisan command –
1 |
php artisan serve |
Now, open the following URL in browser to see the output –
1 |
http://127.0.0.1:8000/ |