Laravel Multi Authentication

v12.1.0 2024-04-23 17:29 UTC


Total Downloads Latest Stable Version Quality Coverage Unit Tests

This package gives you the ability to separate user areas in your application.

E.g, an ecommerce application with customers, sellers, and administrators user areas using auth guards


This package only extends the official laravel/breeze starter kit, it doesn't regenerate the frontend assets [js, css - tailwind, vite, ...]

Therefore, you need to use it after scaffolding basic auth using Breeze.

Breaking Changes

For old versions (Laravel v9 and below) refer to v11


composer require bmatovu/multi-auth --dev


php artisan multi-auth:install admin

Register service provider


  'providers' => [
      * Package Service Providers...
+     App\Modules\Admins\AdminServiceProvider::class,

Register JS entry point in Vite (Inertia - Vue, React)


  export default defineConfig({
      plugins: [
-             input: 'resources/js/app.js',
+             input: [
+                 'resources/js/app.js',
+                 'resources/js/Admins/app.js',
+             ],
-             ssr: 'resources/js/ssr.js',
+             ssr: [
+                 'resources/js/ssr.js',
+                 'resources/js/Admins/ssr.js',
+             ],
              refresh: true,

Read more about Inertia Server Side Rendering

Recompile frontend assets

npm run build

Run Database Migrations

php artisan migrate

Possible approaches for separating user areas

Using sub-domains

Separate user areas by sub-domains.

I would use separate repos for each sub-domain

URI User Group customers sellers administrators

Using URLs*

Separate user areas based on URLs. Restricted with auth guards

* What this package offers

URI User Group customers sellers administrators

Using roles

Restrict access based on the user's roles and permissions

I'd stay away from this approach as it'd more complex to maintain for large projects

URI User Group customers, sellers, administrators