In this series, we will add Laravel Fortify features to the SPA that uses Laravel Sanctum for authentication without using Laravel Jetstream. Laravel Fortify is a headless authentication system for Laravel. It does not care what front-end you choose, instead, it gives you the flexibility to use whatever front-end you want. You are able to specify which views to render for specific actions, but what about SPA or API? SPAs don’t have blade views, it has client-side routing. It may seem a difficult task at first but Laravel Fortify makes this very easy & that is what we cover in this series. We’ll be authenticating SPA using Laravel Fortify without Laravel Jetstream. We will also use LaraveL Sanctum to authenticate the SPA.
Note that this video uses the same demo project that was created & covered in the previous video with Laravel Sanctum, if you don’t know how to authenticate your SPA with Laravel Sanctum I suggest you watch that video first: https://youtu.be/uPKd3q-iaVs
🤝 You can support me by giving my videos a 👍 & by subscribing to the channel ✔️
— Note —
At the time of recording these videos, there was no formal documentation on Laravel Fortify. Now there are docs on the Laravel docs page. Also, there was no way to disable the views by using the configuration, it was added later.
So instead of defining your own routes, you can set the ‘view’ to false & set the ‘prefix’ to ‘api’ in the fortify config file & then you can remove the routes from the api.php routes file & just use the built-in routes. This makes api.php cleaner since you don’t have to define the routes yourself.
I made a quick video at the end of the series explaining the change & made necessary improvements to the routes, you can check that video here: https://youtu.be/2a2FFg40zFI so you should still complete this series & make sure to watch that last video as well
—- Source Code —-
Back-End (Laravel): https://github.com/ggelashvili/laravel-fortify-spa-backend
Front-End (Next.JS): https://github.com/ggelashvili/laravel-fortify-spa-frontend
— Laravel Fortify Without Jetstream Series —
Laravel Fortify Without Jetstream Feature – https://youtu.be/QYJKp1e71xs
Add Two-Factor Authentication Feature – https://youtu.be/EVWmma7nXak
Add User Registration Feature – https://youtu.be/Gt_6XFCLD5Y
Add Account Profile & Password Updates Feature – https://youtu.be/ELLDzzhIefA
Add Password Reset Feature – https://youtu.be/hbP-oodgixA
Authenticate Mobile App With Fortify & Sanctum – https://youtu.be/ymLpLWklzxQ
Updates to Laravel Fortify – https://youtu.be/2a2FFg40zFI