Laravel Breeze vs Laravel Jetstream

January 20, 2023
Written by
Temitope Taiwo Oyedele
Contributor
Opinions expressed by Twilio contributors are their own
Reviewed by

Laravel offers several options for authentication in your applications, ones that provide a robust and modern scaffolding authentication layer. Included in the Laravel Starter Kits, they consist of Laravel Breeze and Laravel Jetstream.

Laravel Breeze is an excellent choice when it comes to getting things running quickly. Jetstream offers two-factor auth, API tokens, and team management. If you are looking for more features then Jetstream is for you.

In this article, you will learn everything you need to know to get started with both packages. This will include installing them, a discussion of their differences and their similarities, and when to use them.

So let's get started.

Prerequisites

To follow this tutorial you must have:

Laravel Breeze

Laravel Breeze implements all of Laravel’s authentication features. It scaffolds a solid authentication flow in your Laravel application complete with sleek views, component system, and a basic dashboard layout; it is built with Laravel Blade.

Laravel Breeze is an upgrade of Laravel UI which sets up basic login, register logout, forgot password, create a password, email verification, and password confirmation functionality. You can customize it to your needs, as it doesn't rely on any job script framework, just Laravel, and Blade. It does use the Tailwind CSS framework to professionally style the front-end.

Laravel Breeze creates all the controllers, routes, and views needed to set up and configure authentication.

Install Laravel Breeze

Create a new Laravel project, then change into the newly created project directory and run the migrations, by running the following command.

composer create-project laravel/laravel project-name
cd project-name

Then, add Laravel Breeze support by running the following commands.

composer require laravel/breeze --dev
php artisan breeze:install

When the commands complete, you will see the following output in the terminal:

INFO  Breeze scaffolding installed successfully.

Next, install the front-end dependencies and compile the frontend assets by running the following command.

npm install && npm run dev

Next, configure Laravel to connect to your database (or use Laravel Sail to set it up instead). Then, after that, launch the application by running the following command, in a new terminal window or tab.

./artisan serve

After the application starts, open the application in your browser of choice. By default, it's available on http://127.0.0.1:8000. You will be able to see the default Laravel page with a login and register link at the top, such as in the example below.

The default Laravel route

Below, you can see an example of the login form, if you click the login link.

The Laravel Breeze login form

Here, you can see an example of the account registration form, if you click the register link.

The Laravel Breeze user registration form

Now, let’s take a look at the file structure.

Breeze's file and directory structure

Routes

The route is a way of creating a request URL for your application. The routes are defined in the routes/auth.php file. If you look in the file you'll see a list of authentication routes which includes routes for logging in, registration, password reset, email validation, password confirmation, and logging out. It is included directly in your web.php file with the following line:

require__DIR__.'/auth.php';

Controllers

The Auth Controller classes are stored in app/Http/Controllers/Auth/. In the folder, are the following controllers:

  • AuthenticatedSessionController.php
  • ConfirmablePasswordController.php
  • EmailVerificationNotificationController.php
  • EmailVerificationPromptController.php
  • NewPasswordController.php
  • PasswordController.php
  • PasswordResetLinkController.php
  • RegisteredUserController.php
  • VerifyEmailController.php

Views

Views separate the controller and domain logic from the presentation logic, and are located in resources/views/auth/. The list of blade views available include:

  • confirm-password.blade.php
  • forgot-password.blade.php
  • login.blade.php
  • register.blade.php
  • reset-password.blade.php
  • verify-email.blade.php

When should you use Breeze?

Breeze is perfect for you when:

  • Your app mainly consists of Blade templates or if you want to rapidly get authentication added to an application without a large amount of opinion needed code
  • You want to modify the authentication functionality of your app quickly
  • You're building an app from scratch that doesn't require the features that Fortify or Jetstream provide
  • You just want a more up-to-date Laravel UI

Now let’s move on to Jetstream.

Laravel Jetstream

Jetstream is more advanced than Breeze, as it contains a lot more features than the basic authentication features. In Jetstream we get:

  • API authentication with Sanctum
  • Email verification
  • Login and registration functionality
  • Session management
  • Team management
  • Two-factor authentication

Jetstream is meant to be a framework within a framework, providing scaffolding support and library features to build a fully functioning Sass dashboard. Laravel Jetstream is free and open-source.

Jetstream uses Laravel Fortify. Fortify defines the routes and controllers for implementing the application's authentication features while the Jetstream UI makes requests to those routes.

When Jetstream is installed, the config/fortify.php configuration file is installed into your application. Use this package if you want to have complete control of your frontend or when you're building an API, or when you don’t need a front end at all. Laravel Jetstream is free and open-source

Installation

Jetstream can be installed using either Composer or the Laravel installer

Install Jetstream with the Laravel installer

First, create a new Laravel project with Jetstream using the Laravel installer, by running the command below.

laravel new project-name --jet

When prompted with "Which Jetstream stack do you prefer?", choose the one that you prefer or are more familiar with.

When prompted with "Will your application use teams? (yes/no) [no]:", press Enter. Then: 

  • change into the newly created project directory, 
  • configure Laravel to connect to your database (or use Laravel Sail to set it up instead)
  • run the migrations, by running the following commands:
cd project-name
php artisan migrate

To make use of the Livewire stack, first publish its Blade components by running the following command:

php artisan vendor:publish --tag=jetstream-views

Then, launch the application by running the following command in the terminal.

php artisan serve

Now, if you open your browser to http://localhost:8000, you'll see the default route render just like in the previous section on Laravel Breeze.

Install Jetstream with Composer

Alternatively, run the following commands to create a new Laravel project with Jetstream using Composer.

composer create-project laravel/laravel project-name
cd project-name
composer require laravel/jetstream

Install Livewire or Inertia

Once that is finished, install your scaffolding tool of choice. For those who prefer to use Livewire with Blade templates, run the following command:

php artisan jetstream:install livewire

For those who prefer to use Inertia with Vue run the following command:

php artisan jetstream:install inertia

You may also add the --teams flag to enable Laravel Jetstream Teams support. This will allow developers to quickly and easily add team management functionality to their application. Among other functionality, it includes the ability to:

  • Create and manage teams
  • Invite and manage team members
  • Assign roles and permissions to team members

It can be useful for applications that need to support multiple teams or user groups, as it provides a built-in, customizable solution for managing these teams within the application.

After the command completes, download and compile the front-end assets with the following command.

npm install && npm run dev

Finally, connect your database and make sure to run your migrations:

php artisan migrate

Launch the application by running the following command in a new terminal window or tab.

php artisan serve

After the application starts, open the application in your browser of choice. By default, it's available on http://127.0.0.1:8000. You will be able to see the default Laravel page with a Login and Register link at the top, such as in the example below.

The default Laravel route

Below, you can see an example of the login form, if you click the Login link.

The Laravel Jetstream login form

Below, you can see an example of the user registration form, if you click the Register link.

The Laravel Jetstream user registration form

Authentication

The newly installed Laravel Jetstream project comes with a login form, two-factor authentication, registration form, password reset, and email verification. The templates for these can all be found in resources/views/auth.

Like I mentioned before, Jetstream uses a package called Laravel Fortify. You can find the Fortify actions in app/actions/Fortify/. The Fortify configurations can be found in config/fortify.php. Here you can make changes like enabling and disabling different features.

Profile Management

Jetstream provides users with user profile management functionality allowing them to update their name, email address, and also upload profile photos. The user profile view is stored in resources/views/profile/update-profile-information-form.blade.php. In case you’re using Inertia you can find the views in resources/js/Pages/Profile/UpdateProfileInformationForm.vue.

Security

Worried about your application security? That’s not a problem. Laravel Jetstream comes with the standard functionality that allows users to update their password and log out which means it’s more than just safe.

What’s more impressive is that it offers Two-factor Authentication (2FA) with QR code, which the users can enable and disable directly. Also, users can log out of other browser sessions as well. The user profile Blade templates can be found in resources/views/profile/. If you are working with Inertia, you can find them in resources/js/Pages/Profile/.

Jetstream's API

Laravel Jetstream uses Laravel Sanctum to provide a token-based API. It is a Laravel package created for the authentication of Single Page Applications (SPAs), mobile applications, and basic token-based APIs.

To know more about APIs with Sanctum, I recommend reading this article. Using Sanctum, each user can generate API tokens with specific permissions like Create, Read, Update, and Delete (CRUD).

Jetstream Teams

In case you used the --team flag during your Jetstream installation, your website would be able to support team creation and management. With the Jetstream Teams feature, each user can create and belong to multiple teams.

When should you use Jetstream?

You should use Jetstream if:

  • You're conversant with Laravel Livewire, Inertia.js, and Tailwind CSS, or you don’t mind taking time to learn them
  • if you are building a new Laravel application and want a pre-built solution for user authentication and other features

Differences

One of the main differences between the two is that Jetstream relies heavily on a front-end stack. It comes with two different options which are the Livewire Blade templates and Inertia Vue templates. If you're used to using Vue for your applications, then go down the Inertia root otherwise go for Livewire and Blade.

Also, if you’ve used Laravel Jetstream before, you will notice that it is a little overwhelming and has a stiff learning curve while Laravel Breeze was developed to get you set up immediately.

Similarities

Their similarities are quite glaring as they are both packages that add pieces of frontend and backend functionality to your application.

Conclusion

So far we’ve explored Laravel Breeze and Jetstream, how to install them, differences, similarities, and also when to use them. Both have outstanding features for the authentication process. These packages were introduced to protect a secured area or restricted actions. You just have to choose the one that best suits your style. Please share if this was helpful.

Temitope Taiwo Oyedele is a software developer and technical writer. He likes to write about things he’s learned and experienced.