{"id":30822542,"url":"https://github.com/thomasorgeval/ngx-better-auth","last_synced_at":"2025-09-06T11:06:48.647Z","repository":{"id":312460523,"uuid":"1047151803","full_name":"thomasorgeval/ngx-better-auth","owner":"thomasorgeval","description":"Better Auth client side implementation for Angular","archived":false,"fork":false,"pushed_at":"2025-08-30T19:38:15.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-30T20:28:03.825Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomasorgeval.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-29T20:34:33.000Z","updated_at":"2025-08-30T19:38:18.000Z","dependencies_parsed_at":"2025-08-30T20:28:12.719Z","dependency_job_id":"6c304535-2f1b-40db-be51-91a3e667cd1f","html_url":"https://github.com/thomasorgeval/ngx-better-auth","commit_stats":null,"previous_names":["thomasorgeval/ngx-better-auth"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/thomasorgeval/ngx-better-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasorgeval%2Fngx-better-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasorgeval%2Fngx-better-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasorgeval%2Fngx-better-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasorgeval%2Fngx-better-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomasorgeval","download_url":"https://codeload.github.com/thomasorgeval/ngx-better-auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasorgeval%2Fngx-better-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273886655,"owners_count":25185511,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-09-06T11:02:08.156Z","updated_at":"2025-09-06T11:06:48.624Z","avatar_url":"https://github.com/thomasorgeval.png","language":"TypeScript","funding_links":[],"categories":["Security and Authentication","TypeScript"],"sub_categories":["Authentication"],"readme":"# ngx-better-auth\n\nAn **Angular 20+ wrapper for [Better Auth](https://github.com/better-auth/better-auth)**. Provides reactive session handling with **signals**, clean **DI provider setup** with **observables**, and modern **guards**.\n\n![npm](https://img.shields.io/npm/v/ngx-better-auth)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/ngx-better-auth)\n![license](https://img.shields.io/npm/l/ngx-better-auth)\n![downloads](https://img.shields.io/npm/dm/ngx-better-auth)\n\n![angular](https://img.shields.io/badge/angular-20+-dd0031?logo=angular\u0026logoColor=white)\n![better-auth](https://img.shields.io/badge/better--auth-1.3.7+-blueviolet)\n\n---\n\n## 🚀 Compatibility\n\n| ngx-better-auth | Angular | Better Auth |\n|-----------------|---------|-------------|\n| `latest`        | `\u003e=20`  | `\u003e=1.3.7`   |\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install ngx-better-auth better-auth\n```\n\n---\n\n## ⚙️ Setup Provider\nFirst, configure your Better Auth client in your application:\n\n```ts\n// app.config.ts\nimport { ApplicationConfig } from '@angular/core'\nimport { provideBetterAuth } from 'ngx-better-auth'\nimport { environment } from './environments/environment'\nimport { adminClient, twoFactorClient, usernameClient } from 'better-auth/client/plugins'\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideBetterAuth({\n      baseURL: environment.apiUrl, // it works also with proxy config\n      basePath: '/auth',   // optional, default is '/api/auth'\n        \n      // Example with plugins\n      plugins: [\n        usernameClient(),\n        twoFactorClient({\n          onTwoFactorRedirect() {\n              window.location.href = '/two-factor-auth'\n          },\n        }),\n        adminClient({\n          ac: accessControl,\n          roles: {\n            admin,\n            moderator,\n            user,\n          },\n        }),\n      ],\n    })\n  ]\n}\n```\n\n## 🧩 Different services\n\nYou can inject different services depending on your needs.  \n**AuthService** provides the core Better Auth client methods (signIn, signOut, signUp, e.g.).  \nThe full list of methods  is available at the end of this README.\n\n## 🔌 Plugin compatibility\n\n### Authentication\n- ✅ Two Factor ➡️ `TwoFactorService`\n- ✅ Username ➡️ `UsernameService`\n- ❌ Anonymous\n- ❌ Phone Number\n- ✅ Magic Link ➡️ `MagicLinkService`\n- ✅ Email OTP ➡️ `EmailOtpService`\n- ✅ Passkey ➡️ `PasskeyService`\n- ✅ Generic OAuth ➡️ `GenericOauthService`\n- ✅ One Tap ➡️ `OneTapService`\n- ❌ Sign In With Ethereum\n\n### Authorization\n- ✅ Admin ➡️ `AdminService`\n- ❌ API Key\n- ❌ MCP\n- ✅ Organization ➡️ `OrganizationService`\n\n### Enterprise\n\n- ❌ OIDC Provider\n- ❌ SSO\n\n### Utility\n\n- ❌ Bearer\n- ❌ Device Authorization\n- ❌ Captcha\n- ❌ Last Login Method\n- ❌ Multi Session\n- ❌ One Time Token\n- ❌ JWT\n\n## 🔄 Real-time Session\n\n### AuthService keeps the session in sync automatically\n- `session` → a signal with the current session or null\n- `isLoggedIn` → a computed boolean\n\n### Demonstration of usage in a component\n```ts\nimport { AuthService } from \"ngx-better-auth\"\nimport { inject } from \"@angular/core\"\n\n@Component({\n    // ...\n})\nexport class MyComponent {\n    private readonly authService = inject(AuthService)\n\n    get isLoggedIn() {\n        return this.authService.isLoggedIn()\n    }\n\n    get userName() {\n        return this.authService.session()?.user.name\n    }\n}\n```\n\n## 🛡️ Guards\nThis library ships with guards to quickly set up route protection.\n\n### Helpers\n- `redirectUnauthorizedTo(['/login'])` → redirect if not logged in\n- `redirectLoggedInTo(['/'])` → redirect if already logged in \n- `hasRole(['admin'], ['/unauthorized'])` → restrict access by role and redirect if not authorized\n\n### Usage in routes\n```ts\nimport { Routes } from '@angular/router'\nimport { canActivate, redirectLoggedInTo, redirectUnauthorizedTo, hasRole } from 'ngx-better-auth'\n\nexport const routes: Routes = [\n  {\n    path: '',\n    component: SomeComponent,\n    ...canActivate(redirectUnauthorizedTo(['/login']))\n  },\n  {\n    path: 'admin',\n    component: AdminComponent,\n    ...canActivate(hasRole(['admin'], ['/unauthorized']))\n  },\n  {\n    path: 'login',\n    component: LoginComponent,\n    ...canActivate(redirectLoggedInTo(['/']))\n  }\n]\n```\n\n## 📋 Full list of AuthService methods\n\n### AuthService\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasorgeval%2Fngx-better-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasorgeval%2Fngx-better-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasorgeval%2Fngx-better-auth/lists"}