Overview:
Nuxt Auth Sanctum is a module that provides a simple way to use Laravel Sanctum with Nuxt. It leverages cookies-based authentication and is SSR-ready. Before using this module, make sure you have already configured Laravel Sanctum on your backend.
Features:
- useSanctumAuth composable for easy access to the current user and authentication methods
- Automated CSRF token header and cookie management
- Support for both CSR and SSR modes
- Pre-configured middleware for pages that require authentication
- Ability to cast current user information to any class
- Compatible with the default Nuxt ofetch client
- TypeScript support
Installation:
To install Nuxt Auth Sanctum, follow these steps:
- Add the
nuxt-auth-sanctum
dependency to your project.
npm install nuxt-auth-sanctum
- Add
'nuxt-auth-sanctum'
to the modules section of yournuxt.config.ts
file.
export default {
//...
modules: [
'nuxt-auth-sanctum',
],
//...
}
Summary:
Nuxt Auth Sanctum is a powerful module that allows you to easily integrate Laravel Sanctum authentication into your Nuxt app. With features such as automated CSRF token management and SSR support, it provides a seamless and secure authentication solution. By following a simple installation process, you can start using Nuxt Auth Sanctum in your project and take advantage of its convenient composables and middleware.