Overview
The Nuxt Sanctum Auth package allows for easy integration of Laravel Sanctum authentication with Nuxt. It is currently in development and only supports SPA or Hybrid mode, with no full SSR support yet.
Features
- Integration of Laravel Sanctum auth with Nuxt
- Works in SPA or Hybrid mode
- Provides automatic redirection after login and logout
- Access to user information
- Use of middlewares for authentication and guest access
- Option to use JWT-token authentication
Installation
To install the Nuxt Sanctum Auth package, follow these steps:
- Import the module into the
nuxt.config.jsfile and disable SSR. Alternatively, you can disable SSR viarouteRulesfor specific pages where authentication or guest middlewares are needed, such as the account section and login page.
// nuxt.config.js
export default {
modules: [
'nuxt-sanctum-auth',
],
// ...
ssr: false,
}
- You can also define options for the package, with the defaults shown in the example below:
// nuxt.config.js
export default {
modules: [
['nuxt-sanctum-auth', {
home: '/',
login: '/login',
logout: '/logout',
}],
],
}
Summary
The Nuxt Sanctum Auth package provides a simple and convenient way to integrate Laravel Sanctum authentication with Nuxt. It offers features such as automatic redirection after login and logout, access to user information, and the ability to use middlewares for authentication and guest access. While still in development and limited to SPA or Hybrid mode, this package shows promise for handling authentication in Nuxt projects.