Laravel Breeze: Authentication Made Simple
Laravel Breeze is a minimal, simple implementation of Laravel's authentication features, including login, registration, password reset, email verification, and password confirmation. It’s the perfect starting point for developers who want a clean, customizable auth system without unnecessary complexity.
- Laravel
- Authentication
- Blade
- Tailwind CSS
What Is Laravel Breeze?
Laravel Breeze is a lightweight authentication starter kit for Laravel applications. It provides:
- Login, registration, password reset, and email verification
- Simple Blade templates styled with Tailwind CSS
- No complex dependencies or frontend frameworks
- Perfect for developers who want a simple, customizable auth system
Breeze is ideal for developers who want to avoid the complexity of Laravel Jetstream or Laravel Fortify but still need a robust authentication system.
Why Use Laravel Breeze?
Laravel Breeze is designed for simplicity and speed. Here’s why you should consider it:
- Minimal Setup: No unnecessary features or bloat.
- Tailwind CSS: Modern, responsive styling out of the box.
- Blade Templates: Easy to customize and extend.
- No JavaScript Frameworks: Uses Alpine.js for minimal interactivity.
- Perfect for APIs and SPAs: Can be used as a backend for frontend frameworks like Vue, React, or Inertia.
Installing Laravel Breeze
Installing Breeze is straightforward. Follow these steps:
# Install Laravel (if you haven't already)
composer create-project laravel/laravel example-app
# Install Breeze
composer require laravel/breeze --dev
# Install Breeze with Blade (default)
php artisan breeze:install blade
# Install dependencies and build assets
npm install && npm run dev
# Run migrations
php artisan migrate
That’s it! Your application now has a fully functional authentication system.
Core Features of Laravel Breeze
1. Login and Registration
Breeze provides pre-built login and registration forms. Users can register, log in, and log out with ease.
// Example: Customizing the registration logic
// app/Http/Controllers/Auth/RegisteredUserController.php
public function store(Request $request)
{
$request->validate([
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|confirmed|min:8',
]);
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
event(new Registered($user));
Auth::login($user);
return redirect(RouteServiceProvider::HOME);
}
2. Password Reset
Forgot your password? Breeze includes a password reset feature with email verification.
// Example: Sending a password reset link
// routes/web.php
use Illuminate\Support\Facades\Password;
Route::post('/forgot-password', function (Request $request) {
$request->validate(['email' => 'required|email']);
$status = Password::sendResetLink(
$request->only('email')
);
return $status === Password::RESET_LINK_SENT
? back()->with(['status' => __($status)])
: back()->withErrors(['email' => __($status)]);
})->middleware('guest')->name('password.email');
3. Email Verification
Ensure users verify their email addresses before accessing protected routes.
// Example: Protecting routes with email verification
// routes/web.php
Route::get('/dashboard', function () {
return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');
4. Password Confirmation
Protect sensitive actions by requiring users to confirm their password.
// Example: Password confirmation middleware
// routes/web.php
Route::get('/settings', function () {
return view('settings');
})->middleware(['auth', 'password.confirm'])->name('settings');
Customizing Laravel Breeze
Breeze is designed to be customizable. Here’s how you can tweak it:
1. Modifying Blade Templates
All Blade templates are located in the resources/views/auth directory. Edit them to match your design.
2. Customizing Routes
Breeze registers its routes in routes/auth.php. Modify or extend them as needed.
// Example: Adding a custom route
// routes/web.php
use App\Http\Controllers\ProfileController;
Route::middleware('auth')->group(function () {
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});
3. Adding New Fields
Need extra fields in the registration form? Update the App\Models\User model, migration, and registration Blade template.
// Example: Adding a 'phone' field to the User model
// app/Models/User.php
protected $fillable = [
'name',
'email',
'password',
'phone', // Add new field
];
// Example: Update the migration
// database/migrations/xxxx_add_phone_to_users_table.php
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('phone')->nullable();
});
}
Using Breeze with Inertia or API
Breeze can also be used with Inertia.js or as an API backend:
# Install Breeze with Inertia
php artisan breeze:install inertia
# Install Breeze with API only
php artisan breeze:install api
This allows you to use Breeze as a backend for SPAs or mobile apps.
// Example: API Authentication with Sanctum
// routes/api.php
use App\Http\Controllers\Auth\AuthenticatedSessionController;
Route::post('/login', [AuthenticatedSessionController::class, 'store']);
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])->middleware('auth:sanctum');
Security Considerations
While Breeze provides a solid foundation, always consider:
- Rate limiting login attempts to prevent brute force attacks.
- Using HTTPS for all authentication routes.
- Regularly updating Laravel and dependencies.
- Customizing password requirements for stronger security.
// Example: Rate limiting login attempts
// app/Http/Middleware/RateLimitLogin.php
public function handle($request, Closure $next)
{
if ($this->limiter->tooManyAttempts($this->throttleKey($request), 5)) {
throw new HttpException(429, 'Too many login attempts. Please try again in 60 seconds.');
}
return $next($request);
}
Common Mistakes with Laravel Breeze
- Not running
npm run devafter installation. - Forgetting to run migrations.
- Overcomplicating the auth system when Breeze is designed to be simple.
- Not customizing the default Blade templates to match your app’s design.
- Ignoring security best practices, such as rate limiting and HTTPS.
Final Thoughts
Laravel Breeze is the perfect choice for developers who want a simple, customizable authentication system without the complexity of Jetstream or Fortify. It’s lightweight, easy to install, and provides all the essential features out of the box.
Whether you're building a small project or a large-scale application, Breeze gives you the flexibility to start simple and scale as needed.
Now that you understand Breeze, it’s time to build something amazing!
Connect with me on LinkedIn and check out my GitHub for more Laravel tips and projects!
