Laravel 10 brings a wealth of features for web application development, with authentication being a core aspect. One of the most powerful ways to implement authentication in Laravel is by using Jetstream, a feature-packed toolkit that makes handling user authentication, registration, email verification, and more, a breeze.
In this blog, we’ll walk you through setting up authentication in Laravel 10 using Jetstream.
Contents
Laravel Jetstream is a modern, application scaffolding system that provides a complete solution for handling authentication, user profiles, team management, and more. It comes with a variety of features like:
Jetstream integrates easily with Tailwind CSS for UI and offers two options for frontend scaffolding:
First, create a new Laravel project using Composer:
composer create-project --prefer-dist laravel/laravel laravel-jetstream
Navigate to your project directory:
cd laravel-jetstream
Next, we need to install Jetstream. You can choose either Livewire or Inertia.js as your stack.
For this tutorial, we’ll use Livewire.
Run the following command:
composer require laravel/jetstream
Once installed, scaffold the Jetstream application with Livewire:
php artisan jetstream:install livewire
After Jetstream is installed, you’ll need to install the JavaScript dependencies and compile your assets.
Run the following commands:
npm install npm run dev
Before you can use authentication, you need to migrate the database. First, set up your .env file with your database credentials. Then, run:
php artisan migrate
This command will create the necessary tables for authentication, including users, password resets, and personal access tokens.
Jetstream comes with a complete authentication system. You can customize the default behavior by modifying the generated files in the app/Http/Controllers/Auth directory.
For example, to customize the registration process, you can edit the RegisteredUserController.php.
Jetstream takes care of routing for authentication. You can find the routes in the routes/web.php file. Here’s a brief overview of the default routes available:
You can access these routes by visiting them in your web browser.
Registration
To allow users to register, navigate to /register in your browser. Fill out the form, and upon submission, a new user will be created in your database.
Login
To log in, go to /login. After entering the credentials, you’ll be redirected to the dashboard.
Password Reset
To test the password reset functionality, navigate to /forgot-password and follow the instructions to reset your password.
You can extend the Jetstream functionality by adding:
To enable two-factor authentication, update the user model to implement the MustVerifyEmail interface and add the necessary routes and views.
Laravel 10’s Jetstream provides a seamless and comprehensive authentication solution, complete with essential features like two-factor authentication, session management, and email verification. Whether you’re building a simple user authentication system or a complex multi-user application with teams, Jetstream has the tools to get you up and running quickly.
With this guide, you should now have a working authentication system using Jetstream in your Laravel 10 application.
Happy coding!
In modern web development, seamless navigation and state management are crucial for delivering a smooth…
Magento Open Source 2.4.8 beta version released on October 8, 2024. The latest release of…
Hello Magento Friends, Creating catalog price rules programmatically in Magento 2 can be a valuable…
As the world of eCommerce continues to thrive, Shopify has become one of the most…
Shopify Remix is an innovative framework that provides a streamlined experience for building fast, dynamic,…
Building a successful eCommerce store requires expertise, and for many businesses, Shopify has become the…