laravelvue.jssingle-page-applicationlaravel-8laravel-jetstream

How to use Jetstream authentication in SPA powered by Vue without using inertia and laravel router?


I am creating a Single Page Application using Laravel 8, Vue and Sanctum for API.

If I use Jetstream for authentication, there is compulsory to use another js Inertia and according to documentation it's saying "you will use Laravel's router instead of Vue router."

Can I use Jetstream without the inertia or without laravel router?


Solution

  • You can can achieve this using laravel ui package and scaffolding for vue. If you want to use Sanctum, prefer it to make stateful and boot your vue app from laravel. It will help handle authentication more securely as you dont need to save token in frontend/JS. Cookie based authentication will be working with your SPA.

    for example : https://medium.com/techvblogs/spa-authentication-using-laravel-9-sanctum-vue-3-and-vite-b1fb1020d754