Laravel Authentication: UI vs Jetstream vs Fortify vs Breeze
Tags: laravel, php, programming, vue
Published: 2021-11-03 01:12:10

In this article, I want to outline as simply as possible the differences between four first-party Laravel packages – UI, Jetstream, Fortify and Breeze. All, to some extent, help you scaffold your apps (or parts of them) so you can get on with the good stuff.

UI (laravel/ui)
Prior to this package's existence, authentication was generated in Laravel with the artisan auth:make command. If you've worked with Laravel for a while, you'll remember this command.

The functionality that auth:make provided was removed and put into a separate package called laravel/ui. This meant you'd have to use Composer to pull this package in, and then issue the registered artisan commands to generate authentication scaffolding.

For a long time, this was the only officially supported scaffold for Laravel. If you didn't use this package, you'd have to build authentication, password resets and other features yourself. This package also gives a choice between using Vue or React and comes with Bootstrap and the required markup by default.

Although considered legacy, you can still use it today!

Use this package if:

The other options seem too complex at this stage in your journey.
You prefer working with Bootstrap and don't want to spend time removing Tailwind (discussed later) from the newer options.
Jetstream
Laravel Jetstream, released alongside Laravel 8, made a massive leap from the laravel/ui package and included a completely different scaffolding experience. At the time of writing, it includes presets for either Laravel Livewire or Inertia.js and removes Bootstrap in favour of Tailwind.

Jetstream also provides more features than laravel/ui out of the box, including profile information updating, two-factor authentication and support for teams.

Under the hood, Jetstream uses Fortify (discussed later) to drive the authentication functionality. By scaffolding an app with Jetstream, you're also pulling in Fortify, so you can use any of the features this provides now, or into the future.

Jetstream operates very differently from laravel/ui by hiding away a lot of the underlying functionality (mainly because it uses Fortify), favouring Actions that allow you to modify what happens when, for example, users register or delete their account. Some of these actions are provided by Fortify, some are actions specifically built for Jetstream.

Jetstream makes heavy use of Blade components to create reusable UI elements like form inputs. Because of this, if you're not familiar with Blade components or want to start heavily customising the UI quickly, you'll have to spend some time re-creating components from scratch with your own styles. This is both a positive and negative, because componentizing common UI elements is a great practice, but with a pre-built solution comes the cost of having ready-built components that you may need to change.

Tailwind is included by default in Jetstream, which is a utility-based CSS framework, although this can be swapped out for another framework or nothing at all. However, you'd have to rebuild all of Jetstream's components because they all use Tailwind styles.

Finally, Jetstream uses Alpine.js, which is a minimal JavaScript framework.

Use Jetstream if:

You're familiar with Laravel Livewire, Inertia and Tailwind, or don't mind spending time learning them and;
You want immediately start building the core functionality of your app without investing much time in boilerplate.

Fortify
Laravel Fortify is a frontend agnostic authentication implementation. This means it doesn't care how you implement the styling or frontend functionality of the features it provides.

Laravel Jetstream (discussed earlier) uses Fortify under the hood to provide features like authentication, recovering passwords, two factor authentication and updating user's profile information.

You can use Fortify on it's own without Jetstream! If you need all of the features that Fortify provides, but want to start the rest of your app (including the frontend) from scratch, Fortify is a great option.

Fortify works by registering all of the controllers you need for actions like registering, logging in and enabling two-factor authentication. All you need to do is tell Fortify what view to render, post the data through and Fortify takes care of the rest. After you've installed Fortify, you'll find an Actions directory published that allows you to modify what happens when actions like registration take place.

Use Fortify if:

You don't want to use Jetstream, but want the majority of the features it provides.
You want complete control of the styling and functionality from the start of building your app.
If Fortify sounds like what you need, check out the Authentication with Laravel Fortify course, which covers implementing all of Fortify's features.

Breeze
Laravel Breeze is the latest scaffold package released, offering a more up-to-date version of laravel/ui. It provides the same authentication functionality as laravel/ui, but uses Tailwind instead of Bootstrap, and does not include presets for Vue or React.

Although Breeze uses Tailwind, it's much easier to swap this out for something else compared to Jetstream.

Breeze does not use Fortify under the hood, but instead publishes controllers to your app so they're easier to modify (like the laravel/ui package).

Breeze does still use Blade components where applicable, so if you decide to use Breeze, make sure to read up on these, or swap the Blade components out with something else.

Use Breeze if:

You just want a more up-to-date laravel/ui.
You'd like to modify the authentication functionality of your app quickly.
You're building an app from the ground up that doesn't requires the features that Fortify or Jetstream provide.
Whatever you're building, you'll find a package from this selection that suits you. Sure, there's a learning curve, but you'll spend a lot less time building features you expect by default, and more time on the actual workings of your app.

Collected & Edited
Credit: Laravel Daily && codecourse