# How to Implement Laravel UI Auth Scaffolding in Laravel 9: A Complete Guide

> Learn how to implement Laravel UI auth scaffolding in your fresh Laravel 9 project. This guide covers installation, generation, asset compilation, and migrations for secure user authentication.

- Repository: [Laravel/framework](https://github.com/laravel/framework)
- Tags: how-to-guide
- Published: 2026-02-16

---

**To add authentication scaffolding to a Laravel 9 project, install the `laravel/ui` package, generate the scaffolding with the `--auth` flag, compile the frontend assets, and run your database migrations.**

Laravel 9 removed the classic `Auth::routes()` functionality from the core framework to keep the base installation lean. To generate the traditional **laravel ui auth scaffolding**—including login, registration, and password reset views—you must explicitly install the optional `laravel/ui` package, which registers the necessary service provider and router macros.

## Why Laravel 9 Requires the UI Package for Authentication

### The Auth Facade Guard Clause

When you call `Auth::routes()` in a fresh Laravel 9 installation, the framework throws a `RuntimeException` with the message:

> *"In order to use the Auth::routes() method, please install the laravel/ui package."*

This guard clause lives in [`src/Illuminate/Support/Facades/Auth.php`](https://github.com/laravel/framework/blob/main/src/Illuminate/Support/Facades/Auth.php) at lines 91-98. The method checks whether the `UiServiceProvider` is loaded; if not, it halts execution immediately. The framework’s integration tests confirm this behavior in [`tests/Integration/Support/AuthFacadeTest.php`](https://github.com/laravel/framework/blob/main/tests/Integration/Support/AuthFacadeTest.php) at lines 11-18, ensuring the exception fires when the UI package is absent.

### What the UI Package Provides

Installing `laravel/ui` registers the `UiServiceProvider`, which bootstraps the authentication layer through a router macro named `auth`. This macro performs three critical tasks:

- **Registers standard routes** for `login`, `register`, `password/reset`, and `password/email`.
- **Binds controller classes** such as `LoginController` and `RegisterController` that handle the authentication logic.
- **Publishes Blade view scaffolding** for the login, registration, and password reset interfaces.

Once the package is installed, calling `Auth::routes()` successfully delegates to this macro, wiring up the complete authentication flow.

## Step-by-Step Implementation Guide

### 1. Create a Fresh Laravel 9 Project

Start by creating a new project using Composer:

```bash
composer create-project laravel/laravel example-app
cd example-app

```

### 2. Install the Laravel UI Package

Require the `laravel/ui` package. Version `^3.2` is the first release that supports Laravel 9:

```bash
composer require laravel/ui "^3.2"

```

### 3. Generate the Authentication Scaffolding

Run the `ui` artisan command with the `--auth` flag. You can choose **Bootstrap**, **Vue**, or **React** as your frontend preset:

```bash

# For Bootstrap scaffolding

php artisan ui bootstrap --auth

# For Vue scaffolding

php artisan ui vue --auth

# For React scaffolding

php artisan ui react --auth

```

This command generates the authentication controllers, routes, and Blade view files.

### 4. Compile Frontend Assets

Install the Node dependencies and compile the assets:

```bash
npm install
npm run dev

```

For production environments, use `npm run build` instead of `npm run dev`.

### 5. Run Database Migrations

The scaffolding includes migrations for the `users` table and password resets. Run the migrations to create these tables:

```bash
php artisan migrate

```

### 6. Verify the Installation

Start the development server and test the authentication endpoints:

```bash
php artisan serve

```

Visit `http://localhost:8000/login` and `http://localhost:8000/register` to confirm the views load correctly and the authentication system is functional.

## Summary

- Laravel 9 removed `Auth::routes()` from the core framework; you must install the `laravel/ui` package to restore this functionality.
- The `Auth` facade in [`src/Illuminate/Support/Facades/Auth.php`](https://github.com/laravel/framework/blob/main/src/Illuminate/Support/Facades/Auth.php) throws a `RuntimeException` if you call `routes()` without the UI package installed.
- The `laravel/ui` package registers `UiServiceProvider`, which defines a router macro that binds authentication controllers and publishes Blade views.
- To implement the scaffolding, require `laravel/ui` version `^3.2`, run `php artisan ui bootstrap --auth` (or `vue`/`react`), compile assets with npm, and run migrations.

## Frequently Asked Questions

### Why was Auth::routes() removed from Laravel 9 core?

The Laravel team removed the classic authentication scaffolding from the core framework to reduce the default installation size and to encourage modern frontend solutions like Laravel Breeze or Jetstream. The `laravel/ui` package remains available as an optional legacy solution for developers who prefer the Bootstrap, Vue, or React scaffolding.

### Can I use Laravel UI with Vue or React instead of Bootstrap?

Yes. The `laravel/ui` package supports three frontend presets. You can generate the authentication scaffolding with Vue by running `php artisan ui vue --auth`, or with React using `php artisan ui react --auth`. Each preset includes the corresponding JavaScript components and build configuration.

### What should I do if I get the "please install the laravel/ui package" error?

If you encounter the `RuntimeException` stating *"In order to use the Auth::routes() method, please install the laravel/ui package"*, you need to run `composer require laravel/ui` in your project root. After installation, the `UiServiceProvider` will register the necessary router macro, and `Auth::routes()` will function correctly.

### Is Laravel UI the only way to add authentication to Laravel 9?

No. While `laravel/ui` provides the classic scaffolding, Laravel 9 also supports **Laravel Breeze** (a minimal, Tailwind CSS-based implementation) and **Laravel Jetstream** (a more robust application starter kit with Livewire or Inertia). These are the officially recommended solutions for new projects, while `laravel/ui` is maintained primarily for legacy compatibility.