Skip to main content

Laravel Breeze API Install Not Working? Fix routes/api.php (Laravel 12 + Livewire 3 Guide)

Fix php artisan breeze:install api issues in Laravel 12. Solve routes/api.php errors, API authentication problems, and Breeze setup mistakes step-by-step.

3 min read
Laravel Breeze API Install Not Working? Fix routes/api.php (Laravel 12 + Livewire 3 Guide)

🔥 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.php not 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.php exists

  • Verify API routes are loaded in RouteServiceProvider

  • Confirm api middleware 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.php not 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.