#OAuth 2.0 without Nuxt server
3 messages · Page 1 of 1 (latest)
Based on the provided knowledge sources, most Nuxt authentication tooling—such as the official nuxt-auth-utils—is designed for use with a Nuxt server (Nitro), where session management and API endpoints are handled within the Nuxt app itself. This approach is ideal for full-stack Nuxt applications, but not required (or always suitable) when you already have a separate backend (like your Laravel OAuth 2.0 server) and are building for both web and mobile.
The knowledge sources confirm that if you have a separate backend, you do not need to use Nuxt’s server directory or its server-side authentication modules. You can simply call your Laravel API endpoints directly from your Nuxt app using tools like useFetch or $fetch. The server directory and related modules are only necessary if you want to create endpoints directly tied to the Nuxt app, such as for simple authentication/authorization or when building a tightly coupled full-stack app. In your case, with a dedicated backend, these are not required or related to your setup Is it required to use server folder in Nuxt 3 when we have API endpoints?.
Unfortunately, the knowledge sources do not mention any client-only Nuxt 4 authentication modules that work seamlessly without a Nuxt server. If you are targeting both web and mobile and cannot use Nuxt’s server features, you will need to handle OAuth 2.0 flows (authorization code, token storage, refresh, etc.) on the client side, likely using standard JavaScript libraries or your own implementation.
Summary:
- You do not need to use Nuxt server or its server-side auth modules if you already have a backend (Laravel OAuth 2.0).
- You can call your backend’s OAuth endpoints directly from your Nuxt app using
useFetchor$fetch. - The knowledge sources do not provide a ready-made, client-only Nuxt 4 auth module for this use case.
- You may need to use a generic OAuth 2.0 JavaScript library or continue with your custom implementation.
If you want to see how Nuxt handles authentication in a full-stack context (for reference), see the Sessions and Authentication guide, but note that it assumes use of the Nuxt server.