π₯ Laravel Breeze API Install Not Working? Fix routes/api.php (Laravel 12 + Livewire 3 Guide)
β Laravel Breeze API Install Not Working?
If you are running:
php artisan breeze:install api
…and facing issues like:
-
routes/api.phpnot working -
API routes returning 404
-
Authentication failing
-
Breeze API not behaving as expected
π Here is the quick fix before anything else.
β‘ Quick Fix (Most Common Solution)
php artisan route:list
php artisan optimize:clear
β Check these immediately:
-
Ensure
routes/api.phpexists -
Verify API routes are loaded in
RouteServiceProvider -
Confirm
apimiddleware group is active -
If using Sanctum → make sure it's installed & configured
π§ Breeze API vs Blade (Important)
Laravel Breeze supports two main setups:
πΉ Blade (Traditional UI)
php artisan breeze:install blade
πΉ API (SPA / Mobile Apps)
php artisan breeze:install api
π Use API version when:
-
Building SPA (React / Vue)
-
Mobile apps
-
Decoupled frontend
π Use Blade when:
-
Traditional Laravel apps
-
Server-rendered UI
π Common Errors with Breeze API Install
These are the most frequent issues developers face:
-
routes/api.phpnot loading -
API routes returning 404
-
Auth guard misconfiguration
-
Sanctum not installed or misconfigured
-
Cache issues (
config,route,view)
π 90% of issues = config + cache problem
π§± Full Laravel 12 + Breeze + Livewire 3 Setup
Now let’s build it properly from scratch.
1. Prerequisites
-
PHP 8.2+
-
Composer
-
Node.js + npm
-
Database (MySQL / SQLite)
php -v
2. Create New Laravel Project
laravel new breeze-livewire-auth
cd breeze-livewire-auth
php artisan migrate
3. Install Laravel Breeze
composer require laravel/breeze --dev
π Choose your stack:
php artisan breeze:install blade
OR
php artisan breeze:install api
Build frontend assets:
npm install
npm run build
Run server:
php artisan serve
Visit:
/login
4. Install Livewire 3
composer require livewire/livewire
Update layout:
@livewireStyles
@livewireScripts
5. Build Livewire Login Component
php artisan make:livewire Auth.LoginForm
Component Logic
class LoginForm extends Component
{
public string $email = '';
public string $password = '';
public bool $remember = false;
protected array $rules = [
'email' => ['required', 'email'],
'password' => ['required'],
];
public function login()
{
if (!Auth::attempt([
'email' => $this->email,
'password' => $this->password,
])) {
$this->addError('email', 'Invalid credentials');
return;
}
session()->regenerate();
return redirect()->intended('/dashboard');
}
}
Blade View
(Keep your existing — already good π)
6. Security Best Practices
-
Use HTTPS always
-
Enable rate limiting
-
Configure email verification
-
Use Laravel Sanctum for API auth
-
Consider 2FA for production
β FAQ
Why is php artisan breeze:install api not working?
Usually due to:
-
Missing API routes
-
Cache issues
-
Sanctum misconfiguration
Where is routes/api.php?
Inside:
/routes/api.php
Handles all API endpoints.
Blade vs API — which should I use?
-
Blade → simple apps
-
API → SPA / mobile apps
π― Conclusion
If your goal is fast Laravel authentication, Breeze is perfect.
If your goal is modern reactive UX, combine it with Livewire 3.
And if you're working with APIs — make sure your Breeze API setup is correctly configured, especially routes/api.php.