@onmax/nuxt-better-auth 0.0.2-alpha.30 → 0.0.2-alpha.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +60 -17
  2. package/dist/module.d.mts +0 -9
  3. package/dist/module.json +2 -2
  4. package/dist/module.mjs +668 -267
  5. package/dist/runtime/app/components/BetterAuthState.d.vue.ts +4 -4
  6. package/dist/runtime/app/components/BetterAuthState.vue +1 -1
  7. package/dist/runtime/app/components/BetterAuthState.vue.d.ts +4 -4
  8. package/dist/runtime/app/composables/useAuthClient.d.ts +9 -0
  9. package/dist/runtime/app/composables/useAuthClient.js +34 -0
  10. package/dist/runtime/app/composables/useAuthClientAction.d.ts +1 -3
  11. package/dist/runtime/app/composables/useAuthClientAction.js +2 -2
  12. package/dist/runtime/app/composables/useAuthRequestFetch.d.ts +1 -1
  13. package/dist/runtime/app/composables/useSignIn.js +2 -2
  14. package/dist/runtime/app/composables/useSignUp.js +2 -2
  15. package/dist/runtime/app/composables/useUserSession.d.ts +5 -4
  16. package/dist/runtime/app/composables/useUserSession.js +91 -218
  17. package/dist/runtime/app/composables/useUserSessionState.d.ts +3 -0
  18. package/dist/runtime/app/composables/useUserSessionState.js +4 -0
  19. package/dist/runtime/app/internal/auth-action-error.js +1 -3
  20. package/dist/runtime/app/internal/auth-action-handles.js +1 -3
  21. package/dist/runtime/app/internal/redirect-helpers.d.ts +4 -0
  22. package/dist/runtime/app/internal/redirect-helpers.js +37 -0
  23. package/dist/runtime/app/internal/session-fetch.d.ts +12 -0
  24. package/dist/runtime/app/internal/session-fetch.js +56 -0
  25. package/dist/runtime/app/internal/utils.d.ts +1 -0
  26. package/dist/runtime/app/internal/utils.js +3 -0
  27. package/dist/runtime/app/internal/vue-safe-auth-proxy.d.ts +3 -0
  28. package/dist/runtime/app/internal/vue-safe-auth-proxy.js +68 -0
  29. package/dist/runtime/app/internal/wrap-auth-method.d.ts +15 -0
  30. package/dist/runtime/app/internal/wrap-auth-method.js +66 -0
  31. package/dist/runtime/app/middleware/auth.global.js +5 -4
  32. package/dist/runtime/app/plugins/session.client.js +2 -1
  33. package/dist/runtime/composables.d.ts +11 -0
  34. package/dist/runtime/composables.js +9 -0
  35. package/dist/runtime/config.d.ts +8 -6
  36. package/dist/runtime/config.js +3 -1
  37. package/dist/runtime/server/api/_better-auth/_schema.d.ts +1 -5
  38. package/dist/runtime/server/api/_better-auth/_schema.js +2 -1
  39. package/dist/runtime/server/api/_better-auth/accounts.get.d.ts +2 -2
  40. package/dist/runtime/server/api/_better-auth/config.get.js +1 -1
  41. package/dist/runtime/server/api/_better-auth/sessions.get.d.ts +2 -2
  42. package/dist/runtime/server/api/_better-auth/users.get.d.ts +2 -2
  43. package/dist/runtime/server/middleware/route-access.js +1 -1
  44. package/dist/runtime/server/utils/auth.d.ts +13 -2
  45. package/dist/runtime/server/utils/auth.js +42 -16
  46. package/dist/runtime/server/utils/session.d.ts +3 -1
  47. package/dist/runtime/server/utils/session.js +175 -1
  48. package/dist/runtime/server/virtual-modules.d.ts +5 -0
  49. package/dist/runtime/types/augment.d.ts +1 -3
  50. package/dist/runtime/types.d.ts +1 -1
  51. package/package.json +33 -26
package/README.md CHANGED
@@ -1,27 +1,70 @@
1
- <p align="center">
2
- <img src="https://raw.githubusercontent.com/onmax/nuxt-better-auth/main/.github/og.png" alt="Nuxt Better Auth" width="100%">
3
- <br>
4
- <sub>Designed by <a href="https://github.com/HugoRCD">HugoRCD</a></sub>
5
- </p>
1
+ # `@onmax/nuxt-better-auth`
6
2
 
7
- <h1 align="center">@onmax/nuxt-better-auth</h1>
3
+ Nuxt module for [Better Auth](https://better-auth.com) with Nuxt-native route protection, SSR-safe session access, auto-imported helpers, and optional NuxtHub-backed schema generation.
8
4
 
9
- <p align="center">Nuxt module for <a href="https://better-auth.com">Better Auth</a></p>
5
+ > [!WARNING]
6
+ > This package is still in alpha. Expect API and behavior changes before a stable release.
10
7
 
11
- <p align="center">
12
- <a href="https://npmjs.com/package/@onmax/nuxt-better-auth"><img src="https://img.shields.io/npm/v/@onmax/nuxt-better-auth/latest.svg?style=flat&colorA=020420&colorB=00DC82" alt="npm version"></a>
13
- <a href="https://npm.chart.dev/@onmax/nuxt-better-auth"><img src="https://img.shields.io/npm/dm/@onmax/nuxt-better-auth.svg?style=flat&colorA=020420&colorB=00DC82" alt="npm downloads"></a>
14
- <a href="https://npmjs.com/package/@onmax/nuxt-better-auth"><img src="https://img.shields.io/npm/l/@onmax/nuxt-better-auth.svg?style=flat&colorA=020420&colorB=00DC82" alt="License"></a>
15
- <a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js" alt="Nuxt"></a>
16
- </p>
8
+ ## Who this is for
17
9
 
18
- > [!WARNING]
19
- > This library is a work in progress and not ready for production use.
10
+ Use this module if you want Better Auth in a Nuxt 4 app and you want the Nuxt-specific pieces handled for you:
11
+
12
+ - `useUserSession()` for reactive auth state
13
+ - `requireUserSession(event)` and related server helpers
14
+ - route protection through `routeRules` and `definePageMeta({ auth })`
15
+ - generated `server/auth.config.ts` and `app/auth.config.ts`
16
+ - optional NuxtHub database integration and schema generation
17
+
18
+ ## Install the module
19
+
20
+ For the fastest path in a Nuxt 4 app:
21
+
22
+ ```bash
23
+ npx nuxi module add @onmax/nuxt-better-auth@alpha
24
+ ```
25
+
26
+ Then create or confirm these files:
27
+
28
+ - `server/auth.config.ts`
29
+ - `app/auth.config.ts`
30
+ - `.env` with `NUXT_BETTER_AUTH_SECRET`
31
+
32
+ For the full setup flow, follow the [installation guide](https://better-auth.nuxt.dev/getting-started/installation).
33
+
34
+ ## Choose your setup path
35
+
36
+ - Use [NuxtHub integration](https://better-auth.nuxt.dev/integrations/nuxthub) if you want the shortest path to database-backed auth.
37
+ - Use [custom database setup](https://better-auth.nuxt.dev/guides/custom-database) if you already have your own database stack.
38
+ - Use [external auth backend](https://better-auth.nuxt.dev/guides/external-auth-backend) if Better Auth runs in a separate service.
39
+ - Use [database-less mode](https://better-auth.nuxt.dev/guides/database-less-mode) for stateless or OAuth-first setups with clear tradeoffs.
20
40
 
21
41
  ## Documentation
22
42
 
23
- **[better-auth.nuxt.dev](https://better-auth.nuxt.dev/)**
43
+ The documentation site is at [better-auth.nuxt.dev](https://better-auth.nuxt.dev).
44
+
45
+ Recommended reading order:
46
+
47
+ 1. [Quickstart](https://better-auth.nuxt.dev/getting-started)
48
+ 2. [Installation](https://better-auth.nuxt.dev/getting-started/installation)
49
+ 3. [Configuration](https://better-auth.nuxt.dev/getting-started/configuration)
50
+ 4. [Client setup](https://better-auth.nuxt.dev/getting-started/client-setup)
51
+ 5. [Route protection](https://better-auth.nuxt.dev/core-concepts/route-protection)
52
+
53
+ ## Development
54
+
55
+ ```bash
56
+ pnpm install
57
+ pnpm dev:docs
58
+ ```
59
+
60
+ Useful commands:
61
+
62
+ - `pnpm dev` to run the playground
63
+ - `pnpm dev:docs` to run the docs site
64
+ - `pnpm lint` to lint the repo
65
+ - `pnpm test` to run the test suite
66
+ - `pnpm build:docs` to build the docs site
24
67
 
25
68
  ## License
26
69
 
27
- MIT
70
+ [MIT](https://github.com/nuxt-modules/better-auth/blob/main/LICENSE)
package/dist/module.d.mts CHANGED
@@ -5,15 +5,6 @@ export { BetterAuthModuleOptions, defineClientAuth, defineServerAuth } from '../
5
5
  import { BetterAuthOptions } from 'better-auth';
6
6
  export { AppSession, Auth, AuthActionError, AuthMeta, AuthMode, AuthRouteRules, AuthSession, AuthSocialProviderId, AuthUser, InferSession, InferUser, RequireSessionOptions, ServerAuthContext, UserMatch } from '../dist/runtime/types.js';
7
7
 
8
- interface RuntimeDefineServerAuthFn {
9
- (...args: unknown[]): unknown;
10
- _count: number;
11
- }
12
- declare global {
13
- var __nuxtBetterAuthDefineServerAuth: RuntimeDefineServerAuthFn | undefined;
14
- var defineServerAuth: RuntimeDefineServerAuthFn | undefined;
15
- }
16
-
17
8
  type DbDialect = 'sqlite' | 'postgresql' | 'mysql';
18
9
 
19
10
  interface BetterAuthDatabaseProviderBuildContext {
package/dist/module.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@onmax/nuxt-better-auth",
3
- "version": "0.0.2-alpha.30",
3
+ "version": "0.0.2-alpha.32",
4
4
  "configKey": "auth",
5
5
  "compatibility": {
6
6
  "nuxt": ">=4.0.0"
7
7
  },
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
- "unbuild": "3.6.1"
10
+ "unbuild": "unknown"
11
11
  }
12
12
  }