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(5mo ago)5221MITPHPPHP ^7.4|^8.0

Since Nov 26Pushed 5mo 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 2d 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

38

—

LowBetter than 83% of packages

Maintenance73

Regular maintenance activity

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

152d 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

[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5752.3M18](/packages/directorytree-ldaprecord-laravel)[illuminate/auth

The Illuminate Auth package.

10528.2M1.2k](/packages/illuminate-auth)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6804.7k6](/packages/hasinhayder-tyro)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1563.1k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

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