@better-auth-ui/core 1.6.0

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 (97) hide show
  1. package/dist/base-paths.d.ts +21 -0
  2. package/dist/base-paths.js +5 -0
  3. package/dist/config/appearance-config.d.ts +23 -0
  4. package/dist/config/appearance-config.js +1 -0
  5. package/dist/config/auth-config.d.ts +87 -0
  6. package/dist/config/auth-config.js +35 -0
  7. package/dist/config/avatar-config.d.ts +35 -0
  8. package/dist/config/avatar-config.js +1 -0
  9. package/dist/config/delete-user-config.d.ts +14 -0
  10. package/dist/config/delete-user-config.js +1 -0
  11. package/dist/config/email-and-password-config.d.ts +37 -0
  12. package/dist/config/email-and-password-config.js +1 -0
  13. package/dist/config/index.d.ts +5 -0
  14. package/dist/config/index.js +5 -0
  15. package/dist/config/settings-config.d.ts +17 -0
  16. package/dist/config/settings-config.js +1 -0
  17. package/dist/config/toast-config.d.ts +58 -0
  18. package/dist/config/toast-config.js +16 -0
  19. package/dist/index.d.ts +6 -0
  20. package/dist/index.js +6 -0
  21. package/dist/lib/auth-callback-options.d.ts +8 -0
  22. package/dist/lib/auth-callback-options.js +1 -0
  23. package/dist/lib/auth-config.d.ts +198 -0
  24. package/dist/lib/auth-config.js +36 -0
  25. package/dist/lib/auth-error.d.ts +9 -0
  26. package/dist/lib/auth-error.js +1 -0
  27. package/dist/lib/auth-hook-options.d.ts +8 -0
  28. package/dist/lib/auth-hook-options.js +1 -0
  29. package/dist/lib/auth-toast.d.ts +24 -0
  30. package/dist/lib/auth-toast.js +10 -0
  31. package/dist/lib/base-paths.d.ts +21 -0
  32. package/dist/lib/base-paths.js +5 -0
  33. package/dist/lib/config/appearance-config.d.ts +23 -0
  34. package/dist/lib/config/appearance-config.js +1 -0
  35. package/dist/lib/config/auth-config.d.ts +70 -0
  36. package/dist/lib/config/auth-config.js +36 -0
  37. package/dist/lib/config/avatar-config.d.ts +35 -0
  38. package/dist/lib/config/avatar-config.js +1 -0
  39. package/dist/lib/config/email-and-password-config.d.ts +37 -0
  40. package/dist/lib/config/email-and-password-config.js +1 -0
  41. package/dist/lib/config/index.d.ts +6 -0
  42. package/dist/lib/config/index.js +6 -0
  43. package/dist/lib/config/settings-config.d.ts +22 -0
  44. package/dist/lib/config/settings-config.js +1 -0
  45. package/dist/lib/config/toast-config.d.ts +24 -0
  46. package/dist/lib/config/toast-config.js +10 -0
  47. package/dist/lib/localization.d.ts +175 -0
  48. package/dist/lib/localization.js +172 -0
  49. package/dist/lib/provider-names.d.ts +12 -0
  50. package/dist/lib/provider-names.js +50 -0
  51. package/dist/lib/toast-config.d.ts +24 -0
  52. package/dist/lib/toast-config.js +10 -0
  53. package/dist/lib/utils.d.ts +32 -0
  54. package/dist/lib/utils.js +116 -0
  55. package/dist/lib/view-paths.d.ts +68 -0
  56. package/dist/lib/view-paths.js +14 -0
  57. package/dist/localization/index.d.ts +35 -0
  58. package/dist/localization/index.js +34 -0
  59. package/dist/localization/localization.d.ts +35 -0
  60. package/dist/localization/localization.js +34 -0
  61. package/dist/localization.d.ts +159 -0
  62. package/dist/localization.js +156 -0
  63. package/dist/provider-names.d.ts +12 -0
  64. package/dist/provider-names.js +50 -0
  65. package/dist/src/index.d.ts +7 -0
  66. package/dist/src/index.js +7 -0
  67. package/dist/src/lib/auth-config.d.ts +148 -0
  68. package/dist/src/lib/auth-config.js +28 -0
  69. package/dist/src/lib/auth-toast.d.ts +24 -0
  70. package/dist/src/lib/auth-toast.js +10 -0
  71. package/dist/src/lib/base-paths.d.ts +9 -0
  72. package/dist/src/lib/base-paths.js +9 -0
  73. package/dist/src/lib/localization.d.ts +145 -0
  74. package/dist/src/lib/localization.js +142 -0
  75. package/dist/src/lib/provider-names.d.ts +12 -0
  76. package/dist/src/lib/provider-names.js +49 -0
  77. package/dist/src/lib/utils.d.ts +1 -0
  78. package/dist/src/lib/utils.js +30 -0
  79. package/dist/src/lib/view-paths.d.ts +30 -0
  80. package/dist/src/lib/view-paths.js +17 -0
  81. package/dist/utils.d.ts +3 -0
  82. package/dist/utils.js +80 -0
  83. package/dist/view-paths.d.ts +30 -0
  84. package/dist/view-paths.js +17 -0
  85. package/package.json +32 -0
  86. package/src/config/appearance-config.ts +24 -0
  87. package/src/config/auth-config.ts +117 -0
  88. package/src/config/avatar-config.ts +39 -0
  89. package/src/config/delete-user-config.ts +14 -0
  90. package/src/config/email-and-password-config.ts +37 -0
  91. package/src/config/index.ts +5 -0
  92. package/src/index.ts +6 -0
  93. package/src/lib/base-paths.ts +26 -0
  94. package/src/lib/localization.ts +259 -0
  95. package/src/lib/provider-names.ts +55 -0
  96. package/src/lib/utils.ts +151 -0
  97. package/src/lib/view-paths.ts +86 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Base path configuration for authentication, settings, and organization routes.
3
+ */
4
+ export type BasePaths = {
5
+ /**
6
+ * Base path for authentication routes
7
+ * @default "/auth"
8
+ */
9
+ auth: string;
10
+ /**
11
+ * Base path for settings routes
12
+ * @default "/settings"
13
+ */
14
+ settings: string;
15
+ /**
16
+ * Base path for organization management routes
17
+ * @default "/organization"
18
+ */
19
+ organization: string;
20
+ };
21
+ export declare const basePaths: BasePaths;
@@ -0,0 +1,5 @@
1
+ export const basePaths = {
2
+ auth: "/auth",
3
+ settings: "/settings",
4
+ organization: "/organization"
5
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Available theme options for the application.
3
+ */
4
+ export type Theme = "system" | "light" | "dark";
5
+ /**
6
+ * Configuration options for appearance/theme settings.
7
+ */
8
+ export type AppearanceConfig = {
9
+ /**
10
+ * Function to set the application theme
11
+ * @param theme - The theme value to set
12
+ */
13
+ setTheme?: (theme: string) => void;
14
+ /**
15
+ * Current theme value
16
+ */
17
+ theme?: string;
18
+ /**
19
+ * Available theme options to display in the theme switcher
20
+ * @default ["system", "light", "dark"]
21
+ */
22
+ themes: Theme[];
23
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,87 @@
1
+ import type { SocialProvider } from "better-auth/social-providers";
2
+ import { type BasePaths } from "../lib/base-paths";
3
+ import { type Localization } from "../lib/localization";
4
+ import { type ViewPaths } from "../lib/view-paths";
5
+ import type { AppearanceConfig } from "./appearance-config";
6
+ import type { AvatarConfig } from "./avatar-config";
7
+ import type { DeleteUserConfig } from "./delete-user-config";
8
+ import type { EmailAndPasswordConfig } from "./email-and-password-config";
9
+ /**
10
+ * Core authentication configuration interface.
11
+ *
12
+ * Defines the base structure for authentication settings including paths,
13
+ * providers, navigation functions, and feature flags.
14
+ */
15
+ export interface AuthConfig {
16
+ /**
17
+ * Appearance/theme configuration
18
+ * @remarks `AppearanceConfig`
19
+ * @default { themes: ["system", "light", "dark"] }
20
+ */
21
+ appearance: AppearanceConfig;
22
+ /**
23
+ * Avatar upload, optimization, and deletion configuration.
24
+ * @remarks `AvatarConfig`
25
+ * @default { enabled: true, resize: resizeAvatar, size: 256, extension: "png" }
26
+ */
27
+ avatar: AvatarConfig;
28
+ /**
29
+ * Base paths for different application sections
30
+ * @remarks `BasePaths`
31
+ */
32
+ basePaths: BasePaths;
33
+ /**
34
+ * Base URL for API endpoints (optional)
35
+ * @default ""
36
+ */
37
+ baseURL: string;
38
+ /**
39
+ * Allow users to delete their account
40
+ * @remarks `DeleteUserConfig`
41
+ */
42
+ deleteUser?: DeleteUserConfig;
43
+ /**
44
+ * Email and password authentication configuration
45
+ * @remarks `EmailAndPasswordConfig`
46
+ */
47
+ emailAndPassword: EmailAndPasswordConfig;
48
+ /**
49
+ * Localization strings for UI components
50
+ * @remarks `Localization`
51
+ */
52
+ localization: Localization;
53
+ /** Whether magic link (passwordless) authentication is enabled */
54
+ magicLink?: boolean;
55
+ /** Whether multi-session support is enabled */
56
+ multiSession?: boolean;
57
+ /**
58
+ * Default redirect path after successful authentication
59
+ * @default "/"
60
+ */
61
+ redirectTo: string;
62
+ /**
63
+ * List of enabled social authentication providers
64
+ * @remarks `SocialProvider[]`
65
+ */
66
+ socialProviders?: SocialProvider[];
67
+ /**
68
+ * View path mappings for different authentication views
69
+ * @remarks `ViewPaths`
70
+ */
71
+ viewPaths: ViewPaths;
72
+ /**
73
+ * Function to navigate to a new path
74
+ * @param options - Navigation options with href and optional replace flag
75
+ * @default window.location.href = href (or window.location.replace if replace: true)
76
+ * @example
77
+ * // TanStack Router
78
+ * navigate={navigate}
79
+ * // Next.js
80
+ * navigate={({href, replace}) => replace ? router.replace(href) : router.push(href)}
81
+ */
82
+ navigate: (options: {
83
+ to: string;
84
+ replace?: boolean;
85
+ }) => void;
86
+ }
87
+ export declare const defaultAuthConfig: AuthConfig;
@@ -0,0 +1,35 @@
1
+ import { basePaths } from "../lib/base-paths";
2
+ import { localization } from "../lib/localization";
3
+ import { resizeAvatar } from "../lib/utils";
4
+ import { viewPaths } from "../lib/view-paths";
5
+ export const defaultAuthConfig = {
6
+ appearance: {
7
+ themes: ["system", "light", "dark"]
8
+ },
9
+ avatar: {
10
+ enabled: true,
11
+ resize: resizeAvatar,
12
+ size: 256,
13
+ extension: "png"
14
+ },
15
+ basePaths,
16
+ baseURL: "",
17
+ emailAndPassword: {
18
+ enabled: true,
19
+ forgotPassword: true,
20
+ rememberMe: false,
21
+ minPasswordLength: 8,
22
+ maxPasswordLength: 128
23
+ },
24
+ redirectTo: "/",
25
+ viewPaths,
26
+ localization,
27
+ navigate: ({ to, replace }) => {
28
+ if (replace) {
29
+ window.location.replace(to);
30
+ }
31
+ else {
32
+ window.location.href = to;
33
+ }
34
+ }
35
+ };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Configuration options for avatar handling.
3
+ */
4
+ export type AvatarConfig = {
5
+ /**
6
+ * Delete the current avatar (e.g. remove from storage).
7
+ * Gets called after the user's avatar is updated to null.
8
+ */
9
+ delete?: (url: string) => Promise<void>;
10
+ /**
11
+ * Whether avatar changing is enabled.
12
+ * @default true
13
+ */
14
+ enabled: boolean;
15
+ /**
16
+ * Output image format.
17
+ * @default "png"
18
+ */
19
+ extension: "png" | "jpg" | "webp" | "inherit";
20
+ /**
21
+ * Resize an image file before upload. Overrides the default resize behavior.
22
+ * @default Resizes to `size` pixels, square-cropped, output as `extension`.
23
+ */
24
+ resize: (file: File, size?: number, extension?: "png" | "jpg" | "webp" | "inherit") => Promise<File>;
25
+ /**
26
+ * Max dimension in pixels for the optimized avatar.
27
+ * @default 256
28
+ */
29
+ size: number;
30
+ /**
31
+ * Upload a file and return the URL where it was stored.
32
+ * When undefined, the image is base64-encoded and saved directly to `user.image`.
33
+ */
34
+ upload?: (file: File) => Promise<string>;
35
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Configuration for account deletion in the UI (mirrors server `user.deleteUser` flags).
3
+ */
4
+ export interface DeleteUserConfig {
5
+ /**
6
+ * Whether the delete user feature is enabled.
7
+ */
8
+ enabled?: boolean;
9
+ /**
10
+ * When `true`, matches server `sendDeleteAccountVerification`: deletion starts by sending a
11
+ * verification email instead of deleting immediately in this request.
12
+ */
13
+ sendDeleteAccountVerification?: boolean;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Configuration options for email and password authentication.
3
+ */
4
+ export type EmailAndPasswordConfig = {
5
+ /**
6
+ * Whether email/password authentication is enabled
7
+ * @default true
8
+ */
9
+ enabled: boolean;
10
+ /**
11
+ * Whether to show a confirm password field on sign-up forms
12
+ */
13
+ confirmPassword?: boolean;
14
+ /**
15
+ * Whether users can reset forgotten passwords
16
+ * @default true
17
+ */
18
+ forgotPassword: boolean;
19
+ /**
20
+ * Maximum password length
21
+ * @default 128
22
+ */
23
+ maxPasswordLength: number;
24
+ /**
25
+ * Minimum password length
26
+ * @default 8
27
+ */
28
+ minPasswordLength: number;
29
+ /**
30
+ * Maximum password length
31
+ * @default 128
32
+ */
33
+ /** Whether to show a "Remember me" checkbox on sign-in forms */
34
+ rememberMe?: boolean;
35
+ /** Whether email verification is required before account activation */
36
+ requireEmailVerification?: boolean;
37
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from "./appearance-config";
2
+ export * from "./auth-config";
3
+ export * from "./avatar-config";
4
+ export * from "./delete-user-config";
5
+ export * from "./email-and-password-config";
@@ -0,0 +1,5 @@
1
+ export * from "./appearance-config";
2
+ export * from "./auth-config";
3
+ export * from "./avatar-config";
4
+ export * from "./delete-user-config";
5
+ export * from "./email-and-password-config";
@@ -0,0 +1,17 @@
1
+ import type { AppearanceConfig } from "./appearance-config";
2
+ import type { AvatarConfig } from "./avatar-config";
3
+ /**
4
+ * Configuration options for user settings.
5
+ */
6
+ export type SettingsConfig = {
7
+ /**
8
+ * Appearance/theme configuration
9
+ * @default { themes: ["system", "light", "dark"] }
10
+ */
11
+ appearance: AppearanceConfig;
12
+ /**
13
+ * Avatar upload, optimization, and deletion configuration.
14
+ * @default { enabled: true, optimize: optimizeAvatar, size: 256 }
15
+ */
16
+ avatar: AvatarConfig;
17
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Function signature for rendering a toast notification.
3
+ *
4
+ * @param message - The message to display in the toast.
5
+ * @param options - Optional configuration for the toast.
6
+ * @param options.action - Action button displayed within the toast.
7
+ * @param options.action.label - Label text for the action button.
8
+ * @param options.action.onClick - Callback invoked when the action button is clicked.
9
+ * @param options.actionProps - Alternative action props (used by some toast libraries).
10
+ * @param options.actionProps.children - Label text for the action button.
11
+ * @param options.actionProps.onClick - Callback invoked when the action button is clicked.
12
+ * @returns A toast identifier (type varies by toast library), or void.
13
+ */
14
+ export type RenderToast = (message?: string, options?: {
15
+ action?: {
16
+ label: string;
17
+ onClick: () => Promise<void> | void;
18
+ };
19
+ actionProps?: {
20
+ children: string;
21
+ onClick: () => Promise<void> | void;
22
+ };
23
+ }) => string | number | unknown;
24
+ /**
25
+ * Function signature for dismissing a toast notification by its ID.
26
+ *
27
+ * @param id - The identifier of the toast to dismiss (returned by {@link RenderToast}).
28
+ * @returns A toast identifier, or void.
29
+ */
30
+ export type DismissToast = (id?: number | string | unknown | any) => string | number | unknown;
31
+ /**
32
+ * Fallback toast implementation using native browser dialogs.
33
+ *
34
+ * Uses `confirm()` for toasts with an action (invokes the action on confirm)
35
+ * and `alert()` for plain messages.
36
+ */
37
+ export declare const defaultToast: RenderToast;
38
+ /**
39
+ * Configuration for toast notifications used throughout the UI.
40
+ *
41
+ * Provide your own toast library functions (e.g. sonner, react-hot-toast)
42
+ * to customize how notifications are displayed.
43
+ */
44
+ export type ToastConfig = {
45
+ /** Display an error toast notification. */
46
+ error: RenderToast;
47
+ /** Display a danger toast notification (e.g. destructive actions). */
48
+ danger?: RenderToast;
49
+ /** Display a success toast notification. */
50
+ success: RenderToast;
51
+ /** Display an informational toast notification. */
52
+ info: RenderToast;
53
+ /**
54
+ * Dismiss a toast notification by its ID.
55
+ * When provided, allows programmatic dismissal of active toasts.
56
+ */
57
+ dismiss?: DismissToast;
58
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Fallback toast implementation using native browser dialogs.
3
+ *
4
+ * Uses `confirm()` for toasts with an action (invokes the action on confirm)
5
+ * and `alert()` for plain messages.
6
+ */
7
+ export const defaultToast = (message, options) => {
8
+ if (options?.action) {
9
+ if (confirm(message)) {
10
+ options.action.onClick();
11
+ }
12
+ }
13
+ else {
14
+ alert(message);
15
+ }
16
+ };
@@ -0,0 +1,6 @@
1
+ export * from "./config";
2
+ export * from "./lib/base-paths";
3
+ export * from "./lib/localization";
4
+ export * from "./lib/provider-names";
5
+ export * from "./lib/utils";
6
+ export * from "./lib/view-paths";
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./config";
2
+ export * from "./lib/base-paths";
3
+ export * from "./lib/localization";
4
+ export * from "./lib/provider-names";
5
+ export * from "./lib/utils";
6
+ export * from "./lib/view-paths";
@@ -0,0 +1,8 @@
1
+ import type { AuthError } from "./auth-error";
2
+ /**
3
+ * Common callback options for auth operations.
4
+ */
5
+ export interface AuthCallbackOptions {
6
+ onError?: (error: AuthError) => unknown | Promise<unknown>;
7
+ onSuccess?: () => unknown | Promise<unknown>;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,198 @@
1
+ import type { SocialProvider } from "better-auth/social-providers";
2
+ import { type Toast } from "./auth-toast";
3
+ import { type Localization } from "./localization";
4
+ import { type ViewPaths } from "./view-paths";
5
+ /**
6
+ * Configuration options for email and password authentication.
7
+ */
8
+ export type EmailAndPasswordConfig = {
9
+ /**
10
+ * Whether email/password authentication is enabled
11
+ * @default true
12
+ */
13
+ enabled: boolean;
14
+ /**
15
+ * Whether to show a confirm password field on sign-up forms
16
+ */
17
+ confirmPassword?: boolean;
18
+ /**
19
+ * Whether users can reset forgotten passwords
20
+ * @default true
21
+ */
22
+ forgotPassword: boolean;
23
+ /**
24
+ * Maximum password length
25
+ * @default 128
26
+ */
27
+ maxPasswordLength?: number;
28
+ /**
29
+ * Minimum password length
30
+ * @default 8
31
+ */
32
+ minPasswordLength?: number;
33
+ /**
34
+ * Maximum password length
35
+ * @default 128
36
+ */
37
+ /** Whether to show a "Remember me" checkbox on sign-in forms */
38
+ rememberMe?: boolean;
39
+ /** Whether email verification is required before account activation */
40
+ requireEmailVerification?: boolean;
41
+ };
42
+ /**
43
+ * Configuration options for avatar handling.
44
+ */
45
+ export type AvatarConfig = {
46
+ /**
47
+ * Delete the current avatar (e.g. remove from storage).
48
+ * When undefined, avatar deletion is disabled.
49
+ */
50
+ delete?: (url: string) => Promise<void>;
51
+ /**
52
+ * Whether avatar changing is enabled.
53
+ * @default true
54
+ */
55
+ enabled?: boolean;
56
+ /**
57
+ * Output image format.
58
+ * @default "png"
59
+ */
60
+ extension?: "png" | "jpg" | "webp" | "inherit";
61
+ /**
62
+ * Resize an image file before upload.
63
+ * @default Resizes to max size, square-cropped, output as configured extension.
64
+ */
65
+ resize?: (file: File, size?: number, extension?: "png" | "jpg" | "webp" | "inherit") => Promise<File>;
66
+ /**
67
+ * Max dimension in pixels for the optimized avatar.
68
+ * @default 256
69
+ */
70
+ size?: number;
71
+ /**
72
+ * Upload a file and return the URL where it was stored.
73
+ * When undefined, the image is base64-encoded and saved directly to `user.image`.
74
+ */
75
+ upload?: (file: File) => Promise<string>;
76
+ };
77
+ /**
78
+ * Available theme options for the application.
79
+ */
80
+ export type Theme = "system" | "light" | "dark";
81
+ /**
82
+ * Configuration options for appearance/theme settings.
83
+ */
84
+ export type AppearanceConfig = {
85
+ /**
86
+ * Function to set the application theme
87
+ * @param theme - The theme value to set
88
+ */
89
+ setTheme?: (theme: string) => void;
90
+ /**
91
+ * Current theme value
92
+ */
93
+ theme?: string;
94
+ /**
95
+ * Available theme options to display in the theme switcher
96
+ * @default ["system", "light", "dark"]
97
+ */
98
+ themes?: Theme[];
99
+ };
100
+ /**
101
+ * Configuration options for user settings.
102
+ */
103
+ export type SettingsConfig = {
104
+ /**
105
+ * Appearance/theme configuration
106
+ * @default { themes: ["system", "light", "dark"] }
107
+ */
108
+ appearance: AppearanceConfig;
109
+ /**
110
+ * Avatar upload, optimization, and deletion configuration.
111
+ * @default { enabled: true, optimize: optimizeAvatar, size: 256 }
112
+ */
113
+ avatar: AvatarConfig;
114
+ /**
115
+ * Whether the settings section is enabled
116
+ * @default true
117
+ */
118
+ enabled?: boolean;
119
+ };
120
+ /**
121
+ * Core authentication configuration interface.
122
+ *
123
+ * Defines the base structure for authentication settings including paths,
124
+ * providers, navigation functions, and feature flags.
125
+ */
126
+ export interface AuthConfig {
127
+ /** Base paths for different application sections */
128
+ basePaths: {
129
+ /**
130
+ * Base path for authentication routes
131
+ * @default "/auth"
132
+ */
133
+ auth: string;
134
+ /**
135
+ * Base path for settings routes
136
+ * @default "/settings"
137
+ */
138
+ settings: string;
139
+ /**
140
+ * Base path for organization management routes
141
+ * @default "/organization"
142
+ */
143
+ organization: string;
144
+ };
145
+ /**
146
+ * Base URL for API endpoints (optional)
147
+ * @default ""
148
+ */
149
+ baseURL: string;
150
+ /**
151
+ * Email and password authentication configuration
152
+ * @default { enabled: true, forgotPassword: true, minPasswordLength: 8, maxPasswordLength: 128 }
153
+ */
154
+ emailAndPassword: EmailAndPasswordConfig;
155
+ /** Localization strings for UI components. */
156
+ localization: Localization;
157
+ /** Whether magic link (passwordless) authentication is enabled */
158
+ magicLink?: boolean;
159
+ /** Whether multi-session support is enabled */
160
+ multiSession?: boolean;
161
+ /**
162
+ * Default redirect path after successful authentication
163
+ * @default "/"
164
+ */
165
+ redirectTo: string;
166
+ /**
167
+ * Settings section configuration
168
+ * @default { enabled: true }
169
+ */
170
+ settings: SettingsConfig;
171
+ /**
172
+ * List of enabled social authentication providers
173
+ * @remarks `SocialProvider[]`
174
+ */
175
+ socialProviders?: SocialProvider[];
176
+ /** View path mappings for different authentication views */
177
+ viewPaths: ViewPaths;
178
+ /**
179
+ * Toast notification configuration for user feedback.
180
+ * @remarks `Toast`
181
+ */
182
+ toast: Toast;
183
+ /**
184
+ * Function to navigate to a new path
185
+ * @param options - Navigation options with href and optional replace flag
186
+ * @default window.location.href = href (or window.location.replace if replace: true)
187
+ * @example
188
+ * // TanStack Router
189
+ * navigate={navigate}
190
+ * // Next.js
191
+ * navigate={({href, replace}) => replace ? router.replace(href) : router.push(href)}
192
+ */
193
+ navigate: (options: {
194
+ to: string;
195
+ replace?: boolean;
196
+ }) => void;
197
+ }
198
+ export declare const defaultConfig: AuthConfig;
@@ -0,0 +1,36 @@
1
+ import { defaultToast } from "./auth-toast";
2
+ import { basePaths } from "./base-paths";
3
+ import { localization } from "./localization";
4
+ import { resizeAvatar } from "./utils";
5
+ import { viewPaths } from "./view-paths";
6
+ export const defaultConfig = {
7
+ basePaths,
8
+ baseURL: "",
9
+ emailAndPassword: {
10
+ enabled: true,
11
+ forgotPassword: true,
12
+ rememberMe: false,
13
+ minPasswordLength: 8,
14
+ maxPasswordLength: 128
15
+ },
16
+ redirectTo: "/",
17
+ settings: {
18
+ appearance: {
19
+ themes: ["system", "light", "dark"]
20
+ },
21
+ avatar: {
22
+ enabled: true,
23
+ resize: resizeAvatar,
24
+ size: 256
25
+ },
26
+ enabled: true
27
+ },
28
+ viewPaths,
29
+ localization,
30
+ navigate: () => { },
31
+ toast: {
32
+ error: defaultToast,
33
+ success: defaultToast,
34
+ info: defaultToast
35
+ }
36
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Error type returned by Better Auth client methods.
3
+ */
4
+ export type AuthError = {
5
+ code?: string;
6
+ message?: string;
7
+ status: number;
8
+ statusText: string;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { AuthError } from "./auth-error";
2
+ /**
3
+ * Common options for auth hooks.
4
+ */
5
+ export interface AuthHookOptions {
6
+ onError?: (error: AuthError) => unknown | Promise<unknown>;
7
+ onSuccess?: () => unknown | Promise<unknown>;
8
+ }
@@ -0,0 +1 @@
1
+ export {};