PHPackages                             mmedia/laravel-spa - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. mmedia/laravel-spa

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

mmedia/laravel-spa
==================

Add required CORS settings and some routes to help with SPA authentication using Fortify and Sanctum

0.0.4(3mo ago)4221MITPHPPHP ^7.4|^8.0

Since Nov 26Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/M-Media-Group/Laravel-SPA)[ Packagist](https://packagist.org/packages/mmedia/laravel-spa)[ Docs](https://github.com/M-Media-Group/laravel-spa)[ RSS](/packages/mmedia-laravel-spa/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

Add required configs for Fortify and Sanctum based SPA auth
===========================================================

[](#add-required-configs-for-fortify-and-sanctum-based-spa-auth)

[![Total Downloads](https://camo.githubusercontent.com/a481daf6d4373d6337ec22f5045f552d45f9e0be72aa3648242f4d93faa12160/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6d656469612f6c61726176656c2d7370612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mmedia/laravel-spa)

Because Fortify is designed to be frontend agnostic, it requires some configuration if you'd like to use it with an SPA on a subdomain and Sanctum. This package provides the required configurations for that.

### What this package does

[](#what-this-package-does)

- Adds CORS paths for Sanctum cookie and Fortify routes, including login, logout, and more
- Forces CORS with\_credentials to true
- Adds API route to get currently authenticated user (both for cookie based auth and API token based auth), /api/user
- Adds optional route to check if email exists (like Google login where it asks you for your email, and depending on if it exists or not, it will either ask you for password or create a new account)
- Forces Fortify config option "views" to true, where each view redirects to the SPA as defined in the config (see below)
- Adds loginView, registerView, twoFactorChallengeView, requestPasswordResetLinkView, resetPasswordView, verifyEmailView, and confirmPasswordView definitions for Fortify that redirect to your SPA app, with fully configurable paths (useful for links sent in emails, for example)
- Forces the Fortify home config option to keep the path defined but prepend it with your SPA URL, or, if its already a URL, keep it as such
- Allows setting the app language via Accept-Language header
- Redirects any non-API route 404s to your SPA app (which also means that if you don't have a home route, it will redirect to your SPA app home)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require mmedia/laravel-spa
```

Usage
-----

[](#usage)

The service provider will automatically add the functionality as described above. You can publish the config file with:

```
php artisan vendor:publish --provider="Mmedia\LaravelSpa\LaravelSpaServiceProvider" --tag="config"
```

The package will automatically add the SetLocale global middleware, so you can change your app locale with the Accept-Language header.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [M Media](https://github.com/mmedia)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance81

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~388 days

Total

4

Last Release

99d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/30b6a50e70c3cb395a88a29d0eae972f46aa11c0e0aa5c6d4e14ea52012fa3f3?d=identicon)[mwargan](/maintainers/mwargan)

---

Top Contributors

[![mwargan](https://avatars.githubusercontent.com/u/13789481?v=4)](https://github.com/mwargan "mwargan (43 commits)")

---

Tags

mmedialaravel-spa

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mmedia-laravel-spa/health.svg)

```
[![Health](https://phpackages.com/badges/mmedia-laravel-spa/health.svg)](https://phpackages.com/packages/mmedia-laravel-spa)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[olssonm/l5-very-basic-auth

Laravel stateless HTTP basic auth without the need for a database

1662.5M1](/packages/olssonm-l5-very-basic-auth)[scaler-tech/laravel-saml2

SAML2 Service Provider integration for Laravel applications, based on OneLogin toolkit

2737.5k](/packages/scaler-tech-laravel-saml2)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)[pschocke/laravel-telegram-login-widget

Easily integrate Telegrams login widget into your Laravel application to send Telegram messages

1610.4k](/packages/pschocke-laravel-telegram-login-widget)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
