{"library":"nuxt-auth-auto-refresh","title":"Nuxt Auth Auto Refresh","description":"The `nuxt-auth-auto-refresh` package provides automatic, periodic token refreshing for applications using the Nuxt Auth Module v5 (`@nuxtjs/auth-next`). Unlike the default Nuxt Auth v5 behavior, which only refreshes tokens immediately before API requests, this module actively monitors token expiration in the background. It polls every 500ms and triggers a refresh if a token is nearing its expiration (specifically, past 75% of its lifetime but not fully expired). This prevents users from being logged out unexpectedly during long sessions without API interaction or when tokens have very short lifespans. The current stable version is 1.0.2. Its release cadence is tied to the Nuxt Auth Module v5, which the README notes is not yet considered stable itself. This module differentiates by proactively managing token validity, enhancing user experience in specific scenarios.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install nuxt-auth-auto-refresh"],"cli":null},"imports":["plugins: [{ src: \"node_modules/nuxt-auth-auto-refresh/dist/index.js\", ssr: false }]"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// nuxt.config.js\nexport default {\n  buildModules: [\n    // Ensure @nuxtjs/auth-next is installed and configured\n    '@nuxtjs/auth-next',\n  ],\n  auth: {\n    strategies: {\n      // Example strategy - replace with your actual strategy\n      local: {\n        token: {\n          property: 'token',\n          global: true,\n          required: true,\n          type: 'Bearer'\n        },\n        user: {\n          property: 'user',\n          autoFetch: true\n        },\n        endpoints: {\n          login: { url: '/api/auth/login', method: 'post' },\n          logout: { url: '/api/auth/logout', method: 'post' },\n          user: { url: '/api/auth/user', method: 'get' }\n        }\n      }\n    },\n    redirect: {\n      login: '/login',\n      logout: '/login',\n      home: '/',\n      callback: '/login'\n    },\n    plugins: [\n      // Add the auto-refresh plugin here\n      { src: 'node_modules/nuxt-auth-auto-refresh/dist/index.js', ssr: false }\n    ]\n  },\n  // ... other nuxt config\n}","lang":"javascript","description":"This configuration snippet demonstrates how to integrate `nuxt-auth-auto-refresh` into your `nuxt.config.js` by adding its distribution path to the `auth.plugins` array. This setup enables periodic token refreshes for your Nuxt Auth v5 application, preventing premature user logouts.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}