Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

swissbrain's avatar

Laravel Fortify in a stateless API

Hello, Im using Laravel Sanctum, Fortify and Vue in a stateful application right now and Im trying to figure out how hard a separation would be after the basic features were already implemented with Fortify and Sanctum as a stateful application. The docs provide this information:

If you are attempting to manually build the authentication layer for an application that offers an API or serves as the backend for a single-page application, it is entirely possible that you will utilize both Laravel Fortify (for user registration, password reset, etc.) and Laravel Sanctum (API token management, session authentication).

What does this mean? If its "entirely possible that you will utilize both Laravel Fortify (for user registration, password reset, etc.) and Laravel Sanctum" why would I need to manually build the authentication layer?

So what would I need do if I still wanted to use fortify (in a stateless API)?

0 likes
4 replies
martinbean's avatar

why would I need to manually build the authentication layer?

@swissbrain You wouldn’t, given Laravel offers about half a dozen different packages for different authentication scenarios.

Fortify provides functionality for stateful authentication but as the potion of the docs you’ve highlighted says, you’d need to use something else (Sanctum or Passport) to add token-based authentication for your stateless API.

swissbrain's avatar

@martinbean The docs state that you can use both.

If you are attempting to manually build the authentication layer for an application that offers an API or ... it is entirely possible that you will utilize both Laravel Fortify ... and Laravel Sanctum

Thats why Im asking, if it would state that its impossible I wouldnt be here asking. The Laravel docs can be a bit vague sometimes...

martinbean's avatar

The docs state that you can use both.

@swissbrain Right? So what’s the problem? Use Fortify for stateful authentication, and Sanctum for token-based authentication for your stateless API.

swissbrain's avatar

@martinbean Well I understood "you can use both" like "you can use both toghether" or as in "at the same time" but maybe thats the language barrier.

Please or to participate in this conversation.