This module provides a simple way to use Laravel Sanctum with Nuxt by leveraging cookies-based authentication. SSR-ready!
useSanctumAuth
composable for easy access to the current user and authentication methodsCSRF
token header and cookie managementCSR
and SSR
modes supportofetch
clientNote: Before using this module, please make sure that you have already configured Laravel Sanctum on your backend. You can find more information about Laravel Sanctum here.
Complete documentation - Nuxt Auth Sanctum docs.
nuxt-auth-sanctum
dependency to your projectnpx nuxi@latest module add nuxt-auth-sanctum
nuxt.config.ts
fileexport default defineNuxtConfig({
modules: ['nuxt-auth-sanctum'],
sanctum: {
baseUrl: 'http://localhost:80', // Laravel API
},
});
That's it! You can now use Nuxt Auth Sanctum in your Nuxt app ✨
For more details, check the documentation here.