{"id":15486077,"url":"https://github.com/nuxt-alt/auth","last_synced_at":"2025-04-05T17:07:35.789Z","repository":{"id":64644383,"uuid":"576467165","full_name":"nuxt-alt/auth","owner":"nuxt-alt","description":"An alternative module to @nuxtjs/auth","archived":false,"fork":false,"pushed_at":"2024-06-24T10:21:31.000Z","size":158,"stargazers_count":115,"open_issues_count":13,"forks_count":22,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T15:08:48.412Z","etag":null,"topics":["auth","cookie","fetch","jwt","module","nuxt","nuxt-module","nuxt3","ssr","static-site","token"],"latest_commit_sha":null,"homepage":"https://nuxt-alt-auth.vercel.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nuxt-alt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-10T00:02:20.000Z","updated_at":"2025-02-15T14:48:32.000Z","dependencies_parsed_at":"2023-09-24T17:56:35.511Z","dependency_job_id":"fa84f197-2dc8-4860-8244-298b13fb3ac6","html_url":"https://github.com/nuxt-alt/auth","commit_stats":{"total_commits":73,"total_committers":8,"mean_commits":9.125,"dds":0.5753424657534247,"last_synced_commit":"d3318fa788c87784e9aea44153457e86dc112c64"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-alt%2Fauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-alt%2Fauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-alt%2Fauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuxt-alt%2Fauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuxt-alt","download_url":"https://codeload.github.com/nuxt-alt/auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369952,"owners_count":20927928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth","cookie","fetch","jwt","module","nuxt","nuxt-module","nuxt3","ssr","static-site","token"],"created_at":"2024-10-02T06:06:14.219Z","updated_at":"2025-04-05T17:07:35.772Z","avatar_url":"https://github.com/nuxt-alt.png","language":"TypeScript","readme":"\u003ch1 align=\"center\"\u003eAuth\u003c/h1\u003e\n\u003cp align=\"center\"\u003eAlternative Auth module for Nuxt\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/@nuxt-alt/auth\"\u003e\n    \u003cimg alt=\"\" src=\"https://img.shields.io/npm/v/@nuxt-alt/auth.svg?style=flat\u0026colorA=18181B\u0026colorB=28CF8D\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/@nuxt-alt/auth\"\u003e\n    \u003cimg alt=\"\" src=\"https://img.shields.io/npm/dt/@nuxt-alt/auth.svg?style=flat\u0026colorA=18181B\u0026colorB=28CF8D\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n## Info\n\nThis module is meant as an alternative to @nuxtjs/auth, except this is for nuxt3 only with no backwards compatibility support.\n\n## Setup\n\n1. Add `@nuxt-alt/auth` and `@nuxt-alt/http` dependency to your project\n\n```bash\nyarn add @nuxt-alt/auth @nuxt-alt/http\n```\n\n2. Add `@nuxt-alt/auth` and `@pinia/nuxt` to the `modules` section of `nuxt.config.ts`\n\n**Note:** you dont need to specify `@nuxt-alt/http`, it will automatically be added but if you want to manually add it, make sure it is below the auth module (and above the proxy module if you are using it). It also doesn't need pinia\nit will use nuxt's `useState` by default.\n\n```ts\nexport default defineNuxtConfig({\n    modules: [\n        '@nuxt-alt/auth'\n    ],\n    auth: {\n        /* module options */\n    }\n});\n\n```\n\n## Documentation\n[Read Documentation](https://nuxt-alt-auth.vercel.app)\n\n## Changes \n\nThe module now uses '@nuxt-alt/http' to function, that module extends ohmyfetch. Please note that if you were using `data` to post data, you now need to use `body` since this is what `ohmyfetch` uses. If you intend to use ssr, please consider using the `@nuxt-alt/proxy` module.\n\n## Composable\n\nA `useAuth()` composable is availale to use to access the auth methods.\n\n## Options\nMost of the options are taken directly from the [@nuxtjs/auth](https://auth.nuxtjs.org/api/options) module. In addition there are some extra options available.\n\n### `globalMiddleware`\n\n- Type: `Boolean`\n- Default: `false`\n\nEnables/disables the middleware to be used globally.\n\n### `enableMiddleware`\n\n- Type: `Boolean`\n- Default: `true`\n\nEnables/disables the built-in middleware.\n\n### `stores.state.namespace`\n\n- Type: `String`\n- Default: `auth`\n\nThis is the namespace to use for nuxt useState.\n\n### `stores.pinia.enabled`\n- Type: `Boolean`\n- Default: `false`\n\nEnable this option to use the pinia store, bey default this is disabled and nuxt's `useState` is used instead.\n\n### `stores.pinia.namespace`\n\n- Type: `String`\n- Default: `auth`\n\nThis is the namespace to use for the pinia store.\n\n### `stores.local.enabled`\n- Type: `Boolean`\n- Default: `true`\n\nEnable this option to use the localStorage store.\n\n### `stores.local.prefix`\n\n- Type: `String`\n- Default: `auth.`\n\nThis sets the localStorage prefix.\n\n### `stores.session.enabled`\n- Type: `Boolean`\n- Default: `true`\n\nEnable this option to use the sessionStorage store.\n\n### `stores.session.prefix`\n\n- Type: `String`\n- Default: `auth.`\n\nSimilar to the localstorage option, this is the prefix for session storage.\n\n### `stores.cookie.enabled`\n- Type: `Boolean`\n- Default: `true`\n\nEnable this option to use the cookie storage.\n\n### `stores.cookie.prefix`\n\n- Type: `String`\n- Default: `auth.`\n\nSimilar to the localstorage option, this is the prefix for the cookie storage.\n\n### `stores.cookie.options`\n\n- Type: `Object`\n- Default: `{ path: '/' }`\n\nThe default cookie storage options.\n\n### `redirectStrategy`\n\n- Type: `query | storage`\n- Default: `storage`\n\nThe type of redirection strategy you want to use, `storage` utilizng localStorage for redirects, `query` utilizing the route query parameters.\n\n### `tokenValidationInterval`\n\n- Type: `Boolean | Number`\n- Default: `false`\n\nThis is experimental. If set to true, default interval is 1000ms, otherwise set time in milliseconds. This is how often the module with attempt to validate the token for expiry.\n\n### `resetOnResponseError`\n\n- Type: `Boolean | Function`\n- Default: `false`\n\nWhen enabled it will reset when there's a 401 error in any of the responses. You are able to turn this into a function to handle this yourself:\n```ts\nauth: {\n    //... module options\n    resetOnResponseError: (error, auth, scheme) =\u003e {\n       if (error.response.status === 401) {\n           scheme.reset?.()\n           auth.redirect('login')\n       }\n   },\n}\n```\n\n## TypeScript (2.6.0+)\nThe user information can be edited like so for TypeScript:\n```ts\ndeclare module '@nuxt-alt/auth' {\n    interface UserInfo {\n        email: string\n        name: string\n    }\n}\n```\n\n## Tokens (Types)\n\nIn addition to [Auth Tokens](https://auth.nuxtjs.org/api/tokens);\n\nBy default the `$auth.strategy` getter uses the `Scheme` type which does not have `token` or `refreshToken` property types. To help with this, a `$auth.refreshStrategy` and a `$auth.tokenStrategy` getter have been added for typing. They all do the same thing, this is just meant for type hinting.\n\n## Oauth2\n\nOauth2 now has client window authentication thanks to this pull request: https://github.com/nuxt-community/auth-module/pull/1746 \n\nProperties have been changed to:\n\n### `clientWindow`\n\n- Type: `Boolean`\n- Default: `false`\n\nEnable/disable the use of a popup for client authentication.\n\n### `clientWidth`\n\n- Type: `Number`\n- Default: `400`\n\nThe width of the client window.\n\n### `clientHieght`\n\n- Type: `Number`\n- Default: `600`\n\nThe width of the client window.\n\n## Aliases\nAvailable aliases to use within nuxt\n\n- `#auth/runtime`\n- `#auth/utils`\n- `#auth/providers`\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxt-alt%2Fauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuxt-alt%2Fauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuxt-alt%2Fauth/lists"}