How to authenticate my Nuxt 3 app users on Laravel Passport ?
Hello Nuxt community,
I'm currently migrating a Nuxt 2 app which authenticated its users on Laravel Passport, through OAuth2 with PKCE flow.
That authentication was made with the amazing @nuxtjs/auth-next module.
After searching the whole Web, I'm afraid Nuxt 3 does not have such a tool...
Which is the "official" auth module for Nuxt 3 ?
Thanks for your help !
3 Replies
Hi @rankusfr. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, there isn't a direct equivalent to the
@nuxtjs/auth-next
module for Nuxt 3 that specifically handles Laravel Passport authentication. However, I can provide some information on authentication options for Nuxt 3 that might be helpful for your migration:
1. Nuxt Auth Utils: Nuxt 3 has an official module called nuxt-auth-utils
which provides utilities for managing client-side and server-side session data. While it doesn't directly support Laravel Passport, it offers a foundation for implementing authentication in Nuxt 3 applications. You can learn more about it in the Nuxt documentation on Sessions and Authentication.
2. Custom Implementation: Given that you're using Laravel Passport with OAuth2 and PKCE flow, you might need to implement a custom authentication solution. You can use Nuxt 3's built-in features like useCookie
composable to manage authentication tokens. Here's a basic example of how you might handle authentication tokens in a plugin:
3. Third-party Solutions: While not officially endorsed by Nuxt, there are community-created solutions that you might want to explore. For example, some developers have used libraries like keycloak-js
with Nuxt 3, although this isn't specific to Laravel Passport.
It's important to note that the authentication landscape for Nuxt 3 is still evolving, and there isn't a direct, official replacement for @nuxtjs/auth-next
at the time of writing this answer.
For the most up-to-date information, I recommend checking the official Nuxt documentation and the Nuxt GitHub repository for any new developments regarding authentication modules.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@899565802775261205> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Hello,
back again...
I tried out @sidebase/nuxt-auth with an example recipe for Laravel Passport : https://auth.sidebase.io/recipes/community/laravel-passport
Such pain, did not achieve anything serious.
Where should I start ? Full Nuxt native (no modules) ? @sidebase/nuxt-auth ? atinux/nuxt-auth-utils ?