@nuxtjs/better-auth 0.0.0 → 0.1.3

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 (95) hide show
  1. package/README.md +67 -0
  2. package/dist/module.d.mts +47 -0
  3. package/dist/module.json +12 -0
  4. package/dist/module.mjs +1468 -0
  5. package/dist/runtime/app/components/BetterAuthState.d.vue.ts +20 -0
  6. package/dist/runtime/app/components/BetterAuthState.vue +9 -0
  7. package/dist/runtime/app/components/BetterAuthState.vue.d.ts +20 -0
  8. package/dist/runtime/app/composables/runWithSessionRefresh.d.ts +1 -0
  9. package/dist/runtime/app/composables/runWithSessionRefresh.js +12 -0
  10. package/dist/runtime/app/composables/useAction.d.ts +2 -0
  11. package/dist/runtime/app/composables/useAction.js +6 -0
  12. package/dist/runtime/app/composables/useAuthAsyncData.d.ts +6 -0
  13. package/dist/runtime/app/composables/useAuthAsyncData.js +16 -0
  14. package/dist/runtime/app/composables/useAuthClient.d.ts +9 -0
  15. package/dist/runtime/app/composables/useAuthClient.js +35 -0
  16. package/dist/runtime/app/composables/useAuthClientAction.d.ts +3 -0
  17. package/dist/runtime/app/composables/useAuthClientAction.js +15 -0
  18. package/dist/runtime/app/composables/useAuthRequestFetch.d.ts +11 -0
  19. package/dist/runtime/app/composables/useAuthRequestFetch.js +4 -0
  20. package/dist/runtime/app/composables/useSignIn.d.ts +16 -0
  21. package/dist/runtime/app/composables/useSignIn.js +8 -0
  22. package/dist/runtime/app/composables/useSignUp.d.ts +5 -0
  23. package/dist/runtime/app/composables/useSignUp.js +8 -0
  24. package/dist/runtime/app/composables/useUserSession.d.ts +23 -0
  25. package/dist/runtime/app/composables/useUserSession.js +247 -0
  26. package/dist/runtime/app/composables/useUserSessionState.d.ts +3 -0
  27. package/dist/runtime/app/composables/useUserSessionState.js +4 -0
  28. package/dist/runtime/app/internal/auth-action-error.d.ts +3 -0
  29. package/dist/runtime/app/internal/auth-action-error.js +33 -0
  30. package/dist/runtime/app/internal/auth-action-handles.d.ts +21 -0
  31. package/dist/runtime/app/internal/auth-action-handles.js +105 -0
  32. package/dist/runtime/app/internal/redirect-helpers.d.ts +4 -0
  33. package/dist/runtime/app/internal/redirect-helpers.js +37 -0
  34. package/dist/runtime/app/internal/session-fetch.d.ts +12 -0
  35. package/dist/runtime/app/internal/session-fetch.js +56 -0
  36. package/dist/runtime/app/internal/utils.d.ts +1 -0
  37. package/dist/runtime/app/internal/utils.js +3 -0
  38. package/dist/runtime/app/internal/vue-safe-auth-proxy.d.ts +3 -0
  39. package/dist/runtime/app/internal/vue-safe-auth-proxy.js +68 -0
  40. package/dist/runtime/app/internal/wrap-auth-method.d.ts +18 -0
  41. package/dist/runtime/app/internal/wrap-auth-method.js +69 -0
  42. package/dist/runtime/app/middleware/auth.global.d.ts +13 -0
  43. package/dist/runtime/app/middleware/auth.global.js +104 -0
  44. package/dist/runtime/app/pages/__better-auth-devtools.d.vue.ts +3 -0
  45. package/dist/runtime/app/pages/__better-auth-devtools.vue +380 -0
  46. package/dist/runtime/app/pages/__better-auth-devtools.vue.d.ts +3 -0
  47. package/dist/runtime/app/plugins/session.client.d.ts +2 -0
  48. package/dist/runtime/app/plugins/session.client.js +16 -0
  49. package/dist/runtime/app/plugins/session.server.d.ts +2 -0
  50. package/dist/runtime/app/plugins/session.server.js +24 -0
  51. package/dist/runtime/composables.d.ts +12 -0
  52. package/dist/runtime/composables.js +10 -0
  53. package/dist/runtime/config.d.ts +100 -0
  54. package/dist/runtime/config.js +13 -0
  55. package/dist/runtime/internal/auth-route-rules.d.ts +1 -0
  56. package/dist/runtime/internal/auth-route-rules.js +24 -0
  57. package/dist/runtime/server/api/_better-auth/_schema.d.ts +4 -0
  58. package/dist/runtime/server/api/_better-auth/_schema.js +12 -0
  59. package/dist/runtime/server/api/_better-auth/accounts.get.d.ts +2 -0
  60. package/dist/runtime/server/api/_better-auth/accounts.get.js +29 -0
  61. package/dist/runtime/server/api/_better-auth/config.get.d.ts +2 -0
  62. package/dist/runtime/server/api/_better-auth/config.get.js +58 -0
  63. package/dist/runtime/server/api/_better-auth/sessions.delete.d.ts +2 -0
  64. package/dist/runtime/server/api/_better-auth/sessions.delete.js +23 -0
  65. package/dist/runtime/server/api/_better-auth/sessions.get.d.ts +2 -0
  66. package/dist/runtime/server/api/_better-auth/sessions.get.js +44 -0
  67. package/dist/runtime/server/api/_better-auth/users.get.d.ts +2 -0
  68. package/dist/runtime/server/api/_better-auth/users.get.js +35 -0
  69. package/dist/runtime/server/api/auth/[...all].d.ts +2 -0
  70. package/dist/runtime/server/api/auth/[...all].js +6 -0
  71. package/dist/runtime/server/internal/nitro-compat.d.ts +1 -0
  72. package/dist/runtime/server/internal/nitro-compat.js +1 -0
  73. package/dist/runtime/server/internal/nitro2.d.ts +8 -0
  74. package/dist/runtime/server/internal/nitro2.js +29 -0
  75. package/dist/runtime/server/internal/nitro3.d.ts +10 -0
  76. package/dist/runtime/server/internal/nitro3.js +60 -0
  77. package/dist/runtime/server/middleware/route-access.d.ts +2 -0
  78. package/dist/runtime/server/middleware/route-access.js +29 -0
  79. package/dist/runtime/server/tsconfig.json +12 -0
  80. package/dist/runtime/server/utils/auth.d.ts +20 -0
  81. package/dist/runtime/server/utils/auth.js +246 -0
  82. package/dist/runtime/server/utils/custom-secondary-storage.d.ts +6 -0
  83. package/dist/runtime/server/utils/custom-secondary-storage.js +8 -0
  84. package/dist/runtime/server/utils/session.d.ts +8 -0
  85. package/dist/runtime/server/utils/session.js +280 -0
  86. package/dist/runtime/server/virtual-modules.d.ts +27 -0
  87. package/dist/runtime/types/augment.d.ts +56 -0
  88. package/dist/runtime/types/augment.js +0 -0
  89. package/dist/runtime/types.d.ts +21 -0
  90. package/dist/runtime/types.js +0 -0
  91. package/dist/runtime/utils/match-user.d.ts +2 -0
  92. package/dist/runtime/utils/match-user.js +13 -0
  93. package/dist/types.d.mts +11 -0
  94. package/package.json +111 -10
  95. package/index.js +0 -1
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # `@nuxtjs/better-auth`
2
+
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.
4
+
5
+ ## Who this is for
6
+
7
+ Use this module if you want Better Auth in a Nuxt 4 app and you want the Nuxt-specific pieces handled for you:
8
+
9
+ - `useUserSession()` for reactive auth state
10
+ - `requireUserSession(event)` and related server helpers
11
+ - route protection through `routeRules` and `definePageMeta({ auth })`
12
+ - generated `server/auth.config.ts` and `app/auth.config.ts`
13
+ - optional NuxtHub database integration and schema generation
14
+
15
+ ## Install the module
16
+
17
+ For the fastest path in a Nuxt 4 app:
18
+
19
+ ```bash
20
+ npx nuxi module add @nuxtjs/better-auth
21
+ ```
22
+
23
+ Then create or confirm these files:
24
+
25
+ - `server/auth.config.ts`
26
+ - `app/auth.config.ts`
27
+ - `.env` with `NUXT_BETTER_AUTH_SECRET`
28
+
29
+ For the full setup flow, follow the [installation guide](https://better-auth.nuxt.dev/getting-started/installation).
30
+
31
+ ## Choose your setup path
32
+
33
+ - Use [NuxtHub integration](https://better-auth.nuxt.dev/integrations/nuxthub) if you want the shortest path to database-backed auth.
34
+ - Use [custom database setup](https://better-auth.nuxt.dev/guides/custom-database) if you already have your own database stack.
35
+ - Use [external auth backend](https://better-auth.nuxt.dev/guides/external-auth-backend) if Better Auth runs in a separate service.
36
+ - Use [database-less mode](https://better-auth.nuxt.dev/guides/database-less-mode) for stateless or OAuth-first setups with clear tradeoffs.
37
+
38
+ ## Documentation
39
+
40
+ The documentation site is at [better-auth.nuxt.dev](https://better-auth.nuxt.dev).
41
+
42
+ Recommended reading order:
43
+
44
+ 1. [Quickstart](https://better-auth.nuxt.dev/getting-started)
45
+ 2. [Installation](https://better-auth.nuxt.dev/getting-started/installation)
46
+ 3. [Configuration](https://better-auth.nuxt.dev/getting-started/configuration)
47
+ 4. [Client setup](https://better-auth.nuxt.dev/getting-started/client-setup)
48
+ 5. [Route protection](https://better-auth.nuxt.dev/core-concepts/route-protection)
49
+
50
+ ## Development
51
+
52
+ ```bash
53
+ pnpm install
54
+ pnpm dev:docs
55
+ ```
56
+
57
+ Useful commands:
58
+
59
+ - `pnpm dev` to run the playground
60
+ - `pnpm dev:docs` to run the docs site
61
+ - `pnpm lint` to lint the repo
62
+ - `pnpm test` to run the test suite
63
+ - `pnpm build:docs` to build the docs site
64
+
65
+ ## License
66
+
67
+ [MIT](https://github.com/nuxt-modules/better-auth/blob/main/LICENSE)
@@ -0,0 +1,47 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { Nuxt } from '@nuxt/schema';
3
+ import { BetterAuthModuleOptions } from '../dist/runtime/config.js';
4
+ export { BetterAuthModuleOptions, defineClientAuth, defineServerAuth } from '../dist/runtime/config.js';
5
+ import { BetterAuthOptions } from 'better-auth';
6
+ export { AppSession, Auth, AuthActionError, AuthMeta, AuthMode, AuthRouteRules, AuthSession, AuthSocialProviderId, AuthUser, InferSession, InferUser, RequireSessionOptions, ServerAuthContext, UserMatch } from '../dist/runtime/types.js';
7
+
8
+ type DbDialect = 'sqlite' | 'postgresql' | 'mysql';
9
+
10
+ interface BetterAuthDatabaseProviderBuildContext {
11
+ hubDialect: DbDialect;
12
+ usePlural: boolean;
13
+ camelCase: boolean;
14
+ }
15
+ interface BetterAuthDatabaseProviderSetupContext {
16
+ nuxt: Nuxt;
17
+ options: BetterAuthModuleOptions;
18
+ clientOnly: boolean;
19
+ }
20
+ interface BetterAuthDatabaseProviderEnabledContext extends BetterAuthDatabaseProviderSetupContext {
21
+ hasHubDbAvailable: boolean;
22
+ }
23
+ interface BetterAuthDatabaseProviderDefinition {
24
+ buildDatabaseCode: (ctx: BetterAuthDatabaseProviderBuildContext) => string;
25
+ setup?: (ctx: BetterAuthDatabaseProviderSetupContext) => void | Promise<void>;
26
+ isEnabled?: (ctx: BetterAuthDatabaseProviderEnabledContext) => boolean;
27
+ priority?: number;
28
+ }
29
+ declare module '@nuxt/schema' {
30
+ interface NuxtHooks {
31
+ /**
32
+ * Extend better-auth config with additional plugins or options.
33
+ * Called after user's auth.config.ts is loaded.
34
+ * @param config - Partial config to merge into the auth options
35
+ */
36
+ 'better-auth:config:extend': (config: Partial<BetterAuthOptions>) => void | Promise<void>;
37
+ /**
38
+ * Register or override Better Auth database providers.
39
+ * Providers are auto-selected via `isEnabled` + `priority`.
40
+ */
41
+ 'better-auth:database:providers': (providers: Record<string, BetterAuthDatabaseProviderDefinition>) => void | Promise<void>;
42
+ }
43
+ }
44
+
45
+ declare const _default: _nuxt_schema.NuxtModule<BetterAuthModuleOptions, BetterAuthModuleOptions, false>;
46
+
47
+ export { _default as default };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@nuxtjs/better-auth",
3
+ "version": "0.1.3",
4
+ "configKey": "auth",
5
+ "compatibility": {
6
+ "nuxt": ">=4.0.0"
7
+ },
8
+ "builder": {
9
+ "@nuxt/module-builder": "1.0.2",
10
+ "unbuild": "unknown"
11
+ }
12
+ }