Nuxt 3 authentication module that provides login, logout, CSRF protection, token management, and global authentication middleware. Version 3.2.1 is the current stable release. It integrates with Nuxt 3's composition API via the `useAuth` composable and supports secure cookie-based tokens with configurable CSRF protection. Key differentiators include built-in CSRF encryption, global middleware options, and automatic token/cookie management with production-like security defaults. Released under the MIT license.
npm install winx-authNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic setup with Nuxt config and a login page using the useAuth composable.
Ensure useAuth() is called within <script setup> or directly in a Vue component's setup() function.
Set enableGlobalAppMiddleware: false in auth config, or use allow404WithoutAuth: true to allow 404 pages.
Use pnpm add winx-auth (version 3.x) instead of the old package.
Set secure: false in development or use HTTPS locally (e.g., via mkcert).
Use randomBytes(22).toString('base64') (as shown in default config) or a secure environment variable.Move the call into a Vue component's <script setup> block or use #imports auto-import.
Run 'npm install winx-auth' (or pnpm/yarn) and ensure nuxt.config.ts has modules: ['winx-auth'].
Set enableGlobalAppMiddleware: false or exclude the login route in middleware options using globalMiddlewareOptions.allow404WithoutAuth or custom middleware.
Check that token.name matches what the API expects, and that cookie options are consistent (httpOnly/secure).
Ensure encryptSecret in nuxt.config matches the secret used to generate the CSRF token on the server side.