@better-auth-ui/react 1.6.2 → 1.6.4

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 (271) hide show
  1. package/dist/components/auth/auth-provider.d.ts +23 -8
  2. package/dist/components/auth/auth-provider.js +32 -17
  3. package/dist/components/{email → auth/email}/email-changed.js +2 -2
  4. package/dist/components/{email → auth/email}/email-localization.js +1 -1
  5. package/dist/components/{email → auth/email}/email-styles.js +1 -1
  6. package/dist/components/{email → auth/email}/email-verification.js +2 -2
  7. package/dist/components/{email → auth/email}/magic-link.js +2 -2
  8. package/dist/components/{email → auth/email}/new-device.js +2 -2
  9. package/dist/components/{email → auth/email}/otp-email.js +2 -2
  10. package/dist/components/{email → auth/email}/password-changed.js +2 -2
  11. package/dist/components/{email → auth/email}/reset-password.js +2 -2
  12. package/dist/email.d.ts +1 -0
  13. package/dist/email.js +11 -0
  14. package/dist/hooks/auth/use-authenticate.d.ts +6 -5
  15. package/dist/hooks/auth/use-authenticate.js +12 -12
  16. package/dist/hooks/auth/use-user.d.ts +18 -311
  17. package/dist/hooks/auth/use-user.js +5 -5
  18. package/dist/hooks/use-auth-mutation.d.ts +17 -0
  19. package/dist/hooks/use-auth-mutation.js +11 -0
  20. package/dist/hooks/use-auth-plugin.d.ts +31 -0
  21. package/dist/hooks/use-auth-plugin.js +10 -0
  22. package/dist/hooks/use-auth-query.d.ts +14 -0
  23. package/dist/hooks/use-auth-query.js +15 -0
  24. package/dist/index.d.ts +35 -34
  25. package/dist/index.js +74 -83
  26. package/dist/lib/auth-client.d.ts +23 -3687
  27. package/dist/lib/auth-plugin.d.ts +59 -0
  28. package/dist/lib/auth-server.d.ts +16 -0
  29. package/dist/mutations/auth/request-password-reset-mutation.d.ts +26 -0
  30. package/dist/mutations/auth/request-password-reset-mutation.js +24 -0
  31. package/dist/mutations/auth/reset-password-mutation.d.ts +25 -0
  32. package/dist/mutations/auth/reset-password-mutation.js +24 -0
  33. package/dist/mutations/auth/send-verification-email-mutation.d.ts +24 -0
  34. package/dist/mutations/auth/send-verification-email-mutation.js +24 -0
  35. package/dist/mutations/auth/sign-in-email-mutation.d.ts +71 -0
  36. package/dist/mutations/auth/sign-in-email-mutation.js +29 -0
  37. package/dist/mutations/auth/sign-in-social-mutation.d.ts +77 -0
  38. package/dist/mutations/auth/sign-in-social-mutation.js +24 -0
  39. package/dist/mutations/auth/sign-out-mutation.d.ts +25 -0
  40. package/dist/mutations/auth/sign-out-mutation.js +28 -0
  41. package/dist/mutations/auth/sign-up-email-mutation.d.ts +105 -0
  42. package/dist/mutations/auth/sign-up-email-mutation.js +29 -0
  43. package/dist/mutations/auth-mutation-options.d.ts +42 -0
  44. package/dist/mutations/auth-mutation-options.js +19 -0
  45. package/dist/mutations/magic-link/sign-in-magic-link-mutation.d.ts +24 -0
  46. package/dist/mutations/magic-link/sign-in-magic-link-mutation.js +24 -0
  47. package/dist/mutations/multi-session/revoke-multi-session-mutation.d.ts +25 -0
  48. package/dist/mutations/multi-session/revoke-multi-session-mutation.js +29 -0
  49. package/dist/mutations/multi-session/set-active-session-mutation.d.ts +62 -0
  50. package/dist/mutations/multi-session/set-active-session-mutation.js +31 -0
  51. package/dist/mutations/passkey/add-passkey-mutation.d.ts +71 -0
  52. package/dist/mutations/passkey/add-passkey-mutation.js +29 -0
  53. package/dist/mutations/passkey/delete-passkey-mutation.d.ts +25 -0
  54. package/dist/mutations/passkey/delete-passkey-mutation.js +29 -0
  55. package/dist/mutations/passkey/sign-in-passkey-mutation.d.ts +105 -0
  56. package/dist/mutations/passkey/sign-in-passkey-mutation.js +29 -0
  57. package/dist/mutations/settings/change-email-mutation.d.ts +25 -0
  58. package/dist/mutations/settings/change-email-mutation.js +29 -0
  59. package/dist/mutations/settings/change-password-mutation.d.ts +78 -0
  60. package/dist/mutations/settings/change-password-mutation.js +24 -0
  61. package/dist/mutations/settings/delete-user-mutation.d.ts +26 -0
  62. package/dist/mutations/settings/delete-user-mutation.js +24 -0
  63. package/dist/mutations/settings/link-social-mutation.d.ts +26 -0
  64. package/dist/mutations/settings/link-social-mutation.js +24 -0
  65. package/dist/mutations/settings/revoke-session-mutation.d.ts +25 -0
  66. package/dist/mutations/settings/revoke-session-mutation.js +29 -0
  67. package/dist/mutations/settings/unlink-account-mutation.d.ts +25 -0
  68. package/dist/mutations/settings/unlink-account-mutation.js +29 -0
  69. package/dist/mutations/settings/update-user-mutation.d.ts +25 -0
  70. package/dist/mutations/settings/update-user-mutation.js +35 -0
  71. package/dist/mutations/username/is-username-available-mutation.d.ts +27 -0
  72. package/dist/mutations/username/is-username-available-mutation.js +24 -0
  73. package/dist/mutations/username/sign-in-username-mutation.d.ts +75 -0
  74. package/dist/mutations/username/sign-in-username-mutation.js +29 -0
  75. package/dist/queries/auth/session-query.d.ts +71 -0
  76. package/dist/queries/auth/session-query.js +30 -0
  77. package/dist/queries/auth-query-options.d.ts +40 -0
  78. package/dist/queries/auth-query-options.js +17 -0
  79. package/dist/queries/multi-session/list-device-sessions-query.d.ts +76 -0
  80. package/dist/queries/multi-session/list-device-sessions-query.js +31 -0
  81. package/dist/queries/passkey/list-passkeys-query.d.ts +74 -0
  82. package/dist/queries/passkey/list-passkeys-query.js +31 -0
  83. package/dist/queries/settings/account-info-query.d.ts +85 -0
  84. package/dist/queries/settings/account-info-query.js +31 -0
  85. package/dist/queries/settings/list-accounts-query.d.ts +76 -0
  86. package/dist/queries/settings/list-accounts-query.js +31 -0
  87. package/dist/queries/settings/list-sessions-query.d.ts +74 -0
  88. package/dist/queries/settings/list-sessions-query.js +31 -0
  89. package/dist/server/queries/auth/session-query.d.ts +57 -0
  90. package/dist/server/queries/auth/session-query.js +13 -0
  91. package/dist/server/queries/multi-session/list-device-sessions-query.d.ts +60 -0
  92. package/dist/server/queries/multi-session/list-device-sessions-query.js +12 -0
  93. package/dist/server/queries/passkey/list-passkeys-query.d.ts +60 -0
  94. package/dist/server/queries/passkey/list-passkeys-query.js +12 -0
  95. package/dist/server/queries/settings/account-info-query.d.ts +68 -0
  96. package/dist/server/queries/settings/account-info-query.js +12 -0
  97. package/dist/server/queries/settings/list-accounts-query.d.ts +60 -0
  98. package/dist/server/queries/settings/list-accounts-query.js +12 -0
  99. package/dist/server/queries/settings/list-sessions-query.d.ts +60 -0
  100. package/dist/server/queries/settings/list-sessions-query.js +12 -0
  101. package/dist/server.d.ts +7 -0
  102. package/dist/server.js +7 -0
  103. package/package.json +24 -22
  104. package/src/components/auth/auth-provider.tsx +87 -24
  105. package/src/components/{email → auth/email}/email-changed.tsx +1 -1
  106. package/src/components/{email → auth/email}/email-verification.tsx +1 -1
  107. package/src/components/{email → auth/email}/magic-link.tsx +1 -1
  108. package/src/components/{email → auth/email}/new-device.tsx +1 -1
  109. package/src/components/{email → auth/email}/otp-email.tsx +1 -1
  110. package/src/components/{email → auth/email}/password-changed.tsx +1 -1
  111. package/src/components/{email → auth/email}/reset-password.tsx +1 -1
  112. package/src/email.ts +1 -0
  113. package/src/hooks/auth/use-authenticate.ts +13 -10
  114. package/src/hooks/auth/use-user.ts +12 -8
  115. package/src/hooks/use-auth-mutation.ts +47 -0
  116. package/src/hooks/use-auth-plugin.ts +50 -0
  117. package/src/hooks/use-auth-query.ts +40 -0
  118. package/src/index.ts +35 -34
  119. package/src/lib/auth-client.ts +33 -31
  120. package/src/lib/auth-plugin.ts +75 -0
  121. package/src/lib/auth-server.ts +30 -0
  122. package/src/mutations/auth/request-password-reset-mutation.ts +58 -0
  123. package/src/mutations/auth/reset-password-mutation.ts +60 -0
  124. package/src/mutations/auth/send-verification-email-mutation.ts +58 -0
  125. package/src/mutations/auth/sign-in-email-mutation.ts +78 -0
  126. package/src/mutations/auth/sign-in-social-mutation.ts +64 -0
  127. package/src/mutations/auth/sign-out-mutation.ts +71 -0
  128. package/src/mutations/auth/sign-up-email-mutation.ts +74 -0
  129. package/src/mutations/auth-mutation-options.ts +94 -0
  130. package/src/mutations/magic-link/sign-in-magic-link-mutation.ts +59 -0
  131. package/src/mutations/multi-session/revoke-multi-session-mutation.ts +70 -0
  132. package/src/mutations/multi-session/set-active-session-mutation.ts +98 -0
  133. package/src/mutations/passkey/add-passkey-mutation.ts +66 -0
  134. package/src/mutations/passkey/delete-passkey-mutation.ts +66 -0
  135. package/src/mutations/passkey/sign-in-passkey-mutation.ts +74 -0
  136. package/src/mutations/settings/change-email-mutation.ts +67 -0
  137. package/src/mutations/settings/change-password-mutation.ts +59 -0
  138. package/src/mutations/settings/delete-user-mutation.ts +59 -0
  139. package/src/mutations/settings/link-social-mutation.ts +59 -0
  140. package/src/mutations/settings/revoke-session-mutation.ts +69 -0
  141. package/src/mutations/settings/unlink-account-mutation.ts +67 -0
  142. package/src/mutations/settings/update-user-mutation.ts +82 -0
  143. package/src/mutations/username/is-username-available-mutation.ts +62 -0
  144. package/src/mutations/username/sign-in-username-mutation.ts +74 -0
  145. package/src/queries/auth/session-query.ts +135 -0
  146. package/src/queries/auth-query-options.ts +83 -0
  147. package/src/queries/multi-session/list-device-sessions-query.ts +177 -0
  148. package/src/queries/passkey/list-passkeys-query.ts +154 -0
  149. package/src/queries/settings/account-info-query.ts +158 -0
  150. package/src/queries/settings/list-accounts-query.ts +156 -0
  151. package/src/queries/settings/list-sessions-query.ts +154 -0
  152. package/src/server/queries/auth/session-query.ts +94 -0
  153. package/src/server/queries/multi-session/list-device-sessions-query.ts +102 -0
  154. package/src/server/queries/passkey/list-passkeys-query.ts +100 -0
  155. package/src/server/queries/settings/account-info-query.ts +101 -0
  156. package/src/server/queries/settings/list-accounts-query.ts +101 -0
  157. package/src/server/queries/settings/list-sessions-query.ts +101 -0
  158. package/src/server.ts +7 -0
  159. package/dist/core.d.ts +0 -1
  160. package/dist/core.js +0 -1
  161. package/dist/hooks/auth/use-auth-mutation.d.ts +0 -18
  162. package/dist/hooks/auth/use-auth-mutation.js +0 -13
  163. package/dist/hooks/auth/use-auth-query.d.ts +0 -24
  164. package/dist/hooks/auth/use-auth-query.js +0 -13
  165. package/dist/hooks/auth/use-is-username-available.d.ts +0 -19
  166. package/dist/hooks/auth/use-is-username-available.js +0 -12
  167. package/dist/hooks/auth/use-request-password-reset.d.ts +0 -25
  168. package/dist/hooks/auth/use-request-password-reset.js +0 -12
  169. package/dist/hooks/auth/use-reset-password.d.ts +0 -39
  170. package/dist/hooks/auth/use-reset-password.js +0 -12
  171. package/dist/hooks/auth/use-send-verification-email.d.ts +0 -23
  172. package/dist/hooks/auth/use-send-verification-email.js +0 -12
  173. package/dist/hooks/auth/use-session.d.ts +0 -9
  174. package/dist/hooks/auth/use-session.js +0 -15
  175. package/dist/hooks/auth/use-sign-in-email.d.ts +0 -52
  176. package/dist/hooks/auth/use-sign-in-email.js +0 -18
  177. package/dist/hooks/auth/use-sign-in-magic-link.d.ts +0 -31
  178. package/dist/hooks/auth/use-sign-in-magic-link.js +0 -12
  179. package/dist/hooks/auth/use-sign-in-passkey.d.ts +0 -58
  180. package/dist/hooks/auth/use-sign-in-passkey.js +0 -18
  181. package/dist/hooks/auth/use-sign-in-social.d.ts +0 -92
  182. package/dist/hooks/auth/use-sign-in-social.js +0 -12
  183. package/dist/hooks/auth/use-sign-in-username.d.ts +0 -53
  184. package/dist/hooks/auth/use-sign-in-username.js +0 -18
  185. package/dist/hooks/auth/use-sign-out.d.ts +0 -18
  186. package/dist/hooks/auth/use-sign-out.js +0 -18
  187. package/dist/hooks/auth/use-sign-up-email.d.ts +0 -1269
  188. package/dist/hooks/auth/use-sign-up-email.js +0 -18
  189. package/dist/hooks/settings/use-account-info.d.ts +0 -17
  190. package/dist/hooks/settings/use-account-info.js +0 -21
  191. package/dist/hooks/settings/use-add-passkey.d.ts +0 -43
  192. package/dist/hooks/settings/use-add-passkey.js +0 -18
  193. package/dist/hooks/settings/use-change-email.d.ts +0 -24
  194. package/dist/hooks/settings/use-change-email.js +0 -18
  195. package/dist/hooks/settings/use-change-password.d.ts +0 -53
  196. package/dist/hooks/settings/use-change-password.js +0 -12
  197. package/dist/hooks/settings/use-delete-passkey.d.ts +0 -21
  198. package/dist/hooks/settings/use-delete-passkey.js +0 -18
  199. package/dist/hooks/settings/use-delete-user.d.ts +0 -41
  200. package/dist/hooks/settings/use-delete-user.js +0 -12
  201. package/dist/hooks/settings/use-link-social.d.ts +0 -46
  202. package/dist/hooks/settings/use-link-social.js +0 -12
  203. package/dist/hooks/settings/use-list-accounts.d.ts +0 -20
  204. package/dist/hooks/settings/use-list-accounts.js +0 -21
  205. package/dist/hooks/settings/use-list-device-sessions.d.ts +0 -11
  206. package/dist/hooks/settings/use-list-device-sessions.js +0 -21
  207. package/dist/hooks/settings/use-list-sessions.d.ts +0 -20
  208. package/dist/hooks/settings/use-list-sessions.js +0 -21
  209. package/dist/hooks/settings/use-list-user-passkeys.d.ts +0 -11
  210. package/dist/hooks/settings/use-list-user-passkeys.js +0 -21
  211. package/dist/hooks/settings/use-revoke-multi-session.d.ts +0 -19
  212. package/dist/hooks/settings/use-revoke-multi-session.js +0 -18
  213. package/dist/hooks/settings/use-revoke-session.d.ts +0 -19
  214. package/dist/hooks/settings/use-revoke-session.js +0 -18
  215. package/dist/hooks/settings/use-set-active-session.d.ts +0 -37
  216. package/dist/hooks/settings/use-set-active-session.js +0 -21
  217. package/dist/hooks/settings/use-unlink-account.d.ts +0 -21
  218. package/dist/hooks/settings/use-unlink-account.js +0 -18
  219. package/dist/hooks/settings/use-update-user.d.ts +0 -11
  220. package/dist/hooks/settings/use-update-user.js +0 -25
  221. package/dist/lib/auth-client.js +0 -11
  222. package/dist/lib/auth-config.d.ts +0 -43
  223. package/dist/lib/auth-context.d.ts +0 -2
  224. package/dist/lib/auth-context.js +0 -6
  225. package/src/core.ts +0 -1
  226. package/src/hooks/auth/use-auth-mutation.ts +0 -56
  227. package/src/hooks/auth/use-auth-query.ts +0 -50
  228. package/src/hooks/auth/use-is-username-available.ts +0 -22
  229. package/src/hooks/auth/use-request-password-reset.ts +0 -22
  230. package/src/hooks/auth/use-reset-password.ts +0 -21
  231. package/src/hooks/auth/use-send-verification-email.ts +0 -21
  232. package/src/hooks/auth/use-session.ts +0 -27
  233. package/src/hooks/auth/use-sign-in-email.ts +0 -34
  234. package/src/hooks/auth/use-sign-in-magic-link.ts +0 -21
  235. package/src/hooks/auth/use-sign-in-passkey.ts +0 -34
  236. package/src/hooks/auth/use-sign-in-social.ts +0 -21
  237. package/src/hooks/auth/use-sign-in-username.ts +0 -34
  238. package/src/hooks/auth/use-sign-out.ts +0 -33
  239. package/src/hooks/auth/use-sign-up-email.ts +0 -34
  240. package/src/hooks/settings/use-account-info.ts +0 -31
  241. package/src/hooks/settings/use-add-passkey.ts +0 -32
  242. package/src/hooks/settings/use-change-email.ts +0 -33
  243. package/src/hooks/settings/use-change-password.ts +0 -19
  244. package/src/hooks/settings/use-delete-passkey.ts +0 -32
  245. package/src/hooks/settings/use-delete-user.ts +0 -19
  246. package/src/hooks/settings/use-link-social.ts +0 -19
  247. package/src/hooks/settings/use-list-accounts.ts +0 -29
  248. package/src/hooks/settings/use-list-device-sessions.ts +0 -34
  249. package/src/hooks/settings/use-list-sessions.ts +0 -28
  250. package/src/hooks/settings/use-list-user-passkeys.ts +0 -30
  251. package/src/hooks/settings/use-revoke-multi-session.ts +0 -30
  252. package/src/hooks/settings/use-revoke-session.ts +0 -30
  253. package/src/hooks/settings/use-set-active-session.ts +0 -47
  254. package/src/hooks/settings/use-unlink-account.ts +0 -30
  255. package/src/hooks/settings/use-update-user.ts +0 -43
  256. package/src/lib/auth-config.ts +0 -48
  257. package/src/lib/auth-context.ts +0 -6
  258. /package/dist/components/{email → auth/email}/email-changed.d.ts +0 -0
  259. /package/dist/components/{email → auth/email}/email-localization.d.ts +0 -0
  260. /package/dist/components/{email → auth/email}/email-styles.d.ts +0 -0
  261. /package/dist/components/{email → auth/email}/email-verification.d.ts +0 -0
  262. /package/dist/components/{email → auth/email}/index.d.ts +0 -0
  263. /package/dist/components/{email → auth/email}/index.js +0 -0
  264. /package/dist/components/{email → auth/email}/magic-link.d.ts +0 -0
  265. /package/dist/components/{email → auth/email}/new-device.d.ts +0 -0
  266. /package/dist/components/{email → auth/email}/otp-email.d.ts +0 -0
  267. /package/dist/components/{email → auth/email}/password-changed.d.ts +0 -0
  268. /package/dist/components/{email → auth/email}/reset-password.d.ts +0 -0
  269. /package/src/components/{email → auth/email}/email-localization.tsx +0 -0
  270. /package/src/components/{email → auth/email}/email-styles.tsx +0 -0
  271. /package/src/components/{email → auth/email}/index.ts +0 -0
@@ -0,0 +1,59 @@
1
+ import { AuthPluginBase, AuthView } from '@better-auth-ui/core';
2
+ import { ComponentType, ReactNode } from 'react';
3
+ export type { AuthPluginViewPaths } from '@better-auth-ui/core';
4
+ /** Props for plugin-contributed auth buttons (e.g. passkey, magic link). */
5
+ export type AuthButtonProps = {
6
+ className?: string;
7
+ children?: ReactNode;
8
+ /** Current auth view — lets buttons context-switch (e.g. show "back to sign-in"). */
9
+ view?: AuthView;
10
+ };
11
+ /** Props for plugin-contributed cards under `/settings/security`. */
12
+ export type SecurityCardProps = {
13
+ className?: string;
14
+ children?: ReactNode;
15
+ };
16
+ /** Props for plugin-contributed cards under `/settings/account`. */
17
+ export type AccountCardProps = {
18
+ className?: string;
19
+ children?: ReactNode;
20
+ };
21
+ /** Props for plugin-contributed items in the `UserButton` dropdown. */
22
+ export type UserMenuItemProps = {
23
+ className?: string;
24
+ };
25
+ /** Framework-agnostic slot component shapes. UI packages narrow these via `TComponents`. */
26
+ export type AuthPluginComponents = {
27
+ /** Rendered below the submit button in auth forms. */
28
+ authButtons?: ComponentType<AuthButtonProps>[];
29
+ /** Rendered as cards inside security settings. */
30
+ securityCards?: ComponentType<SecurityCardProps>[];
31
+ /** Rendered as cards inside account settings. */
32
+ accountCards?: ComponentType<AccountCardProps>[];
33
+ /** Rendered as items inside the `UserButton` dropdown. */
34
+ userMenuItems?: ComponentType<UserMenuItemProps>[];
35
+ };
36
+ /** Plugin view overrides keyed by `AuthPluginViewPaths`. Always replaces the built-in view. */
37
+ export type AuthPluginViews<TAuthViewProps, TSettingsViewProps> = {
38
+ auth?: Record<string, ComponentType<TAuthViewProps>>;
39
+ settings?: Record<string, ComponentType<TSettingsViewProps>>;
40
+ };
41
+ /** Conditional view replacements — only used when the built-in flow isn't viable. */
42
+ export type AuthPluginFallbackViews<TAuthViewProps> = {
43
+ auth?: {
44
+ /** Rendered at `/auth/sign-in` when `emailAndPassword.enabled === false`. */
45
+ signIn?: ComponentType<TAuthViewProps>;
46
+ };
47
+ };
48
+ /**
49
+ * UI-aware plugin definition. UI packages bind the generics in their own
50
+ * `AuthPlugin` re-export so plugin authors don't have to.
51
+ *
52
+ * @typeParam TComponents - Slot component shapes (e.g. heroui variant unions).
53
+ * @typeParam TAuthViewProps - Props the `<Auth>` router spreads onto plugin auth views.
54
+ * @typeParam TSettingsViewProps - Props the `<Settings>` router spreads onto plugin settings views.
55
+ */
56
+ export type AuthPlugin<TComponents = AuthPluginComponents, TAuthViewProps = any, TSettingsViewProps = any> = AuthPluginBase & TComponents & {
57
+ views?: AuthPluginViews<TAuthViewProps, TSettingsViewProps>;
58
+ fallbackViews?: AuthPluginFallbackViews<TAuthViewProps>;
59
+ };
@@ -0,0 +1,16 @@
1
+ import { passkey } from '@better-auth/passkey';
2
+ import { Auth } from 'better-auth';
3
+ import { magicLink, multiSession, username } from 'better-auth/plugins';
4
+ export type AuthServer = Pick<Auth, "api">;
5
+ export type MagicLinkAuthServer = Pick<Auth<{
6
+ plugins: [ReturnType<typeof magicLink>];
7
+ }>, "api">;
8
+ export type MultiSessionAuthServer = Pick<Auth<{
9
+ plugins: [ReturnType<typeof multiSession>];
10
+ }>, "api">;
11
+ export type PasskeyAuthServer = Pick<Auth<{
12
+ plugins: [ReturnType<typeof passkey>];
13
+ }>, "api">;
14
+ export type UsernameAuthServer = Pick<Auth<{
15
+ plugins: [ReturnType<typeof username>];
16
+ }>, "api">;
@@ -0,0 +1,26 @@
1
+ import { BetterFetchError } from 'better-auth/react';
2
+ import { AuthClient } from '../../lib/auth-client';
3
+ export type RequestPasswordResetParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["requestPasswordReset"]>[0];
4
+ export type RequestPasswordResetOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof requestPasswordResetOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
5
+ /**
6
+ * Mutation options factory for requesting a password reset email.
7
+ *
8
+ * @param authClient - The Better Auth client.
9
+ */
10
+ export declare function requestPasswordResetOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
11
+ status: boolean;
12
+ message: string;
13
+ }, BetterFetchError, RequestPasswordResetParams<TAuthClient>, unknown>, "mutationKey">;
14
+ /**
15
+ * Create a mutation for requesting a password reset email.
16
+ *
17
+ * Wraps `authClient.requestPasswordReset` and forwards React Query mutation
18
+ * options such as `onSuccess`, `onError`, and `retry`.
19
+ *
20
+ * @param authClient - The Better Auth client.
21
+ * @param options - React Query options forwarded to `useMutation`.
22
+ */
23
+ export declare function useRequestPasswordReset<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: RequestPasswordResetOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
24
+ status: boolean;
25
+ message: string;
26
+ }, BetterFetchError, RequestPasswordResetParams<TAuthClient>, unknown>;
@@ -0,0 +1,24 @@
1
+ import { authMutationKeys as e } from "@better-auth-ui/core";
2
+ import { mutationOptions as t, useMutation as n } from "@tanstack/react-query";
3
+ //#region src/mutations/auth/request-password-reset-mutation.ts
4
+ function r(n) {
5
+ let r = e.requestPasswordReset;
6
+ return t({
7
+ mutationKey: r,
8
+ mutationFn: (e) => n.requestPasswordReset({
9
+ ...e,
10
+ fetchOptions: {
11
+ ...e?.fetchOptions,
12
+ throw: !0
13
+ }
14
+ })
15
+ });
16
+ }
17
+ function i(e, t) {
18
+ return n({
19
+ ...r(e),
20
+ ...t
21
+ });
22
+ }
23
+ //#endregion
24
+ export { r as requestPasswordResetOptions, i as useRequestPasswordReset };
@@ -0,0 +1,25 @@
1
+ import { BetterFetchError } from 'better-auth/react';
2
+ import { AuthClient } from '../../lib/auth-client';
3
+ export type ResetPasswordParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["resetPassword"]>[0];
4
+ export type ResetPasswordOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof resetPasswordOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
5
+ /**
6
+ * Mutation options factory for completing a password reset.
7
+ *
8
+ * @param authClient - The Better Auth client.
9
+ */
10
+ export declare function resetPasswordOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
11
+ status: boolean;
12
+ }, BetterFetchError, ResetPasswordParams<TAuthClient>, unknown>, "mutationKey">;
13
+ /**
14
+ * Create a mutation for completing a password reset.
15
+ *
16
+ * Wraps `authClient.resetPassword` (using the token from the reset email)
17
+ * and forwards React Query mutation options such as `onSuccess`, `onError`,
18
+ * and `retry`.
19
+ *
20
+ * @param authClient - The Better Auth client.
21
+ * @param options - React Query options forwarded to `useMutation`.
22
+ */
23
+ export declare function useResetPassword<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: ResetPasswordOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
24
+ status: boolean;
25
+ }, BetterFetchError, ResetPasswordParams<TAuthClient>, unknown>;
@@ -0,0 +1,24 @@
1
+ import { authMutationKeys as e } from "@better-auth-ui/core";
2
+ import { mutationOptions as t, useMutation as n } from "@tanstack/react-query";
3
+ //#region src/mutations/auth/reset-password-mutation.ts
4
+ function r(n) {
5
+ let r = e.resetPassword;
6
+ return t({
7
+ mutationKey: r,
8
+ mutationFn: (e) => n.resetPassword({
9
+ ...e,
10
+ fetchOptions: {
11
+ ...e?.fetchOptions,
12
+ throw: !0
13
+ }
14
+ })
15
+ });
16
+ }
17
+ function i(e, t) {
18
+ return n({
19
+ ...r(e),
20
+ ...t
21
+ });
22
+ }
23
+ //#endregion
24
+ export { r as resetPasswordOptions, i as useResetPassword };
@@ -0,0 +1,24 @@
1
+ import { BetterFetchError } from 'better-auth/react';
2
+ import { AuthClient } from '../../lib/auth-client';
3
+ export type SendVerificationEmailParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["sendVerificationEmail"]>[0];
4
+ export type SendVerificationEmailOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof sendVerificationEmailOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
5
+ /**
6
+ * Mutation options factory for sending a verification email.
7
+ *
8
+ * @param authClient - The Better Auth client.
9
+ */
10
+ export declare function sendVerificationEmailOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
11
+ status: boolean;
12
+ }, BetterFetchError, SendVerificationEmailParams<TAuthClient>, unknown>, "mutationKey">;
13
+ /**
14
+ * Create a mutation for sending an email-verification link.
15
+ *
16
+ * Wraps `authClient.sendVerificationEmail` and forwards React Query mutation
17
+ * options such as `onSuccess`, `onError`, and `retry`.
18
+ *
19
+ * @param authClient - The Better Auth client.
20
+ * @param options - React Query options forwarded to `useMutation`.
21
+ */
22
+ export declare function useSendVerificationEmail<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: SendVerificationEmailOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
23
+ status: boolean;
24
+ }, BetterFetchError, SendVerificationEmailParams<TAuthClient>, unknown>;
@@ -0,0 +1,24 @@
1
+ import { authMutationKeys as e } from "@better-auth-ui/core";
2
+ import { mutationOptions as t, useMutation as n } from "@tanstack/react-query";
3
+ //#region src/mutations/auth/send-verification-email-mutation.ts
4
+ function r(n) {
5
+ let r = e.sendVerificationEmail;
6
+ return t({
7
+ mutationKey: r,
8
+ mutationFn: (e) => n.sendVerificationEmail({
9
+ ...e,
10
+ fetchOptions: {
11
+ ...e?.fetchOptions,
12
+ throw: !0
13
+ }
14
+ })
15
+ });
16
+ }
17
+ function i(e, t) {
18
+ return n({
19
+ ...r(e),
20
+ ...t
21
+ });
22
+ }
23
+ //#endregion
24
+ export { r as sendVerificationEmailOptions, i as useSendVerificationEmail };
@@ -0,0 +1,71 @@
1
+ import { BetterFetchError } from 'better-auth/react';
2
+ import { AuthClient } from '../../lib/auth-client';
3
+ export type SignInEmailParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["signIn"]["email"]>[0];
4
+ export type SignInEmailOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof signInEmailOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
5
+ /**
6
+ * Mutation options factory for email/password sign-in.
7
+ *
8
+ * The returned `mutationKey` (`authMutationKeys.signIn.email`) is stable and
9
+ * can be passed to `useIsMutating` or matched inside a global
10
+ * `MutationCache` observer for toast handling.
11
+ *
12
+ * @param authClient - The Better Auth client.
13
+ */
14
+ export declare function signInEmailOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<Omit<{
15
+ redirect: boolean;
16
+ token: string;
17
+ url?: string | undefined;
18
+ user: {
19
+ id: string;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ email: string;
23
+ emailVerified: boolean;
24
+ name: string;
25
+ image?: string | null | undefined | undefined;
26
+ };
27
+ }, "user"> & {
28
+ user: import('better-auth').StripEmptyObjects<{
29
+ id: string;
30
+ createdAt: Date;
31
+ updatedAt: Date;
32
+ email: string;
33
+ emailVerified: boolean;
34
+ name: string;
35
+ image?: string | null | undefined;
36
+ }>;
37
+ }, BetterFetchError, SignInEmailParams<TAuthClient>, unknown>, "mutationKey">;
38
+ /**
39
+ * Create a mutation for email/password sign-in.
40
+ *
41
+ * Wraps `authClient.signIn.email`, resets the session query on success so
42
+ * the new session is refetched, and forwards React Query mutation options
43
+ * such as `onSuccess`, `onError`, and `retry`.
44
+ *
45
+ * @param authClient - The Better Auth client.
46
+ * @param options - React Query options forwarded to `useMutation`.
47
+ */
48
+ export declare function useSignInEmail<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: SignInEmailOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<Omit<{
49
+ redirect: boolean;
50
+ token: string;
51
+ url?: string | undefined;
52
+ user: {
53
+ id: string;
54
+ createdAt: Date;
55
+ updatedAt: Date;
56
+ email: string;
57
+ emailVerified: boolean;
58
+ name: string;
59
+ image?: string | null | undefined | undefined;
60
+ };
61
+ }, "user"> & {
62
+ user: import('better-auth').StripEmptyObjects<{
63
+ id: string;
64
+ createdAt: Date;
65
+ updatedAt: Date;
66
+ email: string;
67
+ emailVerified: boolean;
68
+ name: string;
69
+ image?: string | null | undefined;
70
+ }>;
71
+ }, BetterFetchError, SignInEmailParams<TAuthClient>, unknown>;
@@ -0,0 +1,29 @@
1
+ import { sessionOptions as e } from "../../queries/auth/session-query.js";
2
+ import { authMutationKeys as t } from "@better-auth-ui/core";
3
+ import { mutationOptions as n, useMutation as r, useQueryClient as i } from "@tanstack/react-query";
4
+ //#region src/mutations/auth/sign-in-email-mutation.ts
5
+ function a(e) {
6
+ let r = t.signIn.email;
7
+ return n({
8
+ mutationKey: r,
9
+ mutationFn: (t) => e.signIn.email({
10
+ ...t,
11
+ fetchOptions: {
12
+ ...t?.fetchOptions,
13
+ throw: !0
14
+ }
15
+ })
16
+ });
17
+ }
18
+ function o(t, n) {
19
+ let o = i();
20
+ return r({
21
+ ...a(t),
22
+ ...n,
23
+ onSuccess: async (...r) => {
24
+ o.resetQueries({ queryKey: e(t).queryKey }), await n?.onSuccess?.(...r);
25
+ }
26
+ });
27
+ }
28
+ //#endregion
29
+ export { a as signInEmailOptions, o as useSignInEmail };
@@ -0,0 +1,77 @@
1
+ import { BetterFetchError } from 'better-auth/react';
2
+ import { AuthClient } from '../../lib/auth-client';
3
+ export type SignInSocialParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["signIn"]["social"]>[0];
4
+ export type SignInSocialOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof signInSocialOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
5
+ /**
6
+ * Mutation options factory for social sign-in.
7
+ *
8
+ * The returned `mutationKey` (`["auth", "signIn", "social"]`) is stable and
9
+ * can be passed to `useIsMutating` or matched inside a global
10
+ * `MutationCache` observer for toast handling.
11
+ *
12
+ * @param authClient - The Better Auth client.
13
+ */
14
+ export declare function signInSocialOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
15
+ redirect: boolean;
16
+ url: string;
17
+ } | (Omit<{
18
+ redirect: boolean;
19
+ token: string;
20
+ url: undefined;
21
+ user: {
22
+ id: string;
23
+ createdAt: Date;
24
+ updatedAt: Date;
25
+ email: string;
26
+ emailVerified: boolean;
27
+ name: string;
28
+ image?: string | null | undefined | undefined;
29
+ };
30
+ }, "user"> & {
31
+ user: import('better-auth').StripEmptyObjects<{
32
+ id: string;
33
+ createdAt: Date;
34
+ updatedAt: Date;
35
+ email: string;
36
+ emailVerified: boolean;
37
+ name: string;
38
+ image?: string | null | undefined;
39
+ }>;
40
+ }), BetterFetchError, SignInSocialParams<TAuthClient>, unknown>, "mutationKey">;
41
+ /**
42
+ * Create a mutation for social sign-in.
43
+ *
44
+ * Wraps `authClient.signIn.social` to initiate a provider redirect and
45
+ * forwards React Query mutation options such as `onSuccess`, `onError`,
46
+ * and `retry`.
47
+ *
48
+ * @param authClient - The Better Auth client.
49
+ * @param options - React Query options forwarded to `useMutation`.
50
+ */
51
+ export declare function useSignInSocial<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: SignInSocialOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
52
+ redirect: boolean;
53
+ url: string;
54
+ } | (Omit<{
55
+ redirect: boolean;
56
+ token: string;
57
+ url: undefined;
58
+ user: {
59
+ id: string;
60
+ createdAt: Date;
61
+ updatedAt: Date;
62
+ email: string;
63
+ emailVerified: boolean;
64
+ name: string;
65
+ image?: string | null | undefined | undefined;
66
+ };
67
+ }, "user"> & {
68
+ user: import('better-auth').StripEmptyObjects<{
69
+ id: string;
70
+ createdAt: Date;
71
+ updatedAt: Date;
72
+ email: string;
73
+ emailVerified: boolean;
74
+ name: string;
75
+ image?: string | null | undefined;
76
+ }>;
77
+ }), BetterFetchError, SignInSocialParams<TAuthClient>, unknown>;
@@ -0,0 +1,24 @@
1
+ import { authMutationKeys as e } from "@better-auth-ui/core";
2
+ import { mutationOptions as t, useMutation as n } from "@tanstack/react-query";
3
+ //#region src/mutations/auth/sign-in-social-mutation.ts
4
+ function r(n) {
5
+ let r = e.signIn.social;
6
+ return t({
7
+ mutationKey: r,
8
+ mutationFn: (e) => n.signIn.social({
9
+ ...e,
10
+ fetchOptions: {
11
+ ...e?.fetchOptions,
12
+ throw: !0
13
+ }
14
+ })
15
+ });
16
+ }
17
+ function i(e, t) {
18
+ return n({
19
+ ...r(e),
20
+ ...t
21
+ });
22
+ }
23
+ //#endregion
24
+ export { r as signInSocialOptions, i as useSignInSocial };
@@ -0,0 +1,25 @@
1
+ import { BetterFetchError } from 'better-auth/react';
2
+ import { AuthClient } from '../../lib/auth-client';
3
+ export type SignOutParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["signOut"]>[0];
4
+ export type SignOutOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof signOutOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
5
+ /**
6
+ * Mutation options factory for signing out.
7
+ *
8
+ * @param authClient - The Better Auth client.
9
+ */
10
+ export declare function signOutOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<{
11
+ success: boolean;
12
+ }, BetterFetchError, void | SignOutParams<TAuthClient> | undefined, unknown>, "mutationKey">;
13
+ /**
14
+ * Create a mutation for signing the current user out.
15
+ *
16
+ * Wraps `authClient.signOut`, removes all cached auth queries on success,
17
+ * and forwards React Query mutation options such as `onSuccess`, `onError`,
18
+ * and `retry`.
19
+ *
20
+ * @param authClient - The Better Auth client.
21
+ * @param options - React Query options forwarded to `useMutation`.
22
+ */
23
+ export declare function useSignOut<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: SignOutOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<{
24
+ success: boolean;
25
+ }, BetterFetchError, void | SignOutParams<TAuthClient> | undefined, unknown>;
@@ -0,0 +1,28 @@
1
+ import { authMutationKeys as e, authQueryKeys as t } from "@better-auth-ui/core";
2
+ import { mutationOptions as n, useMutation as r, useQueryClient as i } from "@tanstack/react-query";
3
+ //#region src/mutations/auth/sign-out-mutation.ts
4
+ function a(t) {
5
+ let r = e.signOut;
6
+ return n({
7
+ mutationKey: r,
8
+ mutationFn: (e) => t.signOut({
9
+ ...e ?? {},
10
+ fetchOptions: {
11
+ ...e?.fetchOptions,
12
+ throw: !0
13
+ }
14
+ })
15
+ });
16
+ }
17
+ function o(e, n) {
18
+ let o = i();
19
+ return r({
20
+ ...a(e),
21
+ ...n,
22
+ onSuccess: async (...e) => {
23
+ o.removeQueries({ queryKey: t.all }), await n?.onSuccess?.(...e);
24
+ }
25
+ });
26
+ }
27
+ //#endregion
28
+ export { a as signOutOptions, o as useSignOut };
@@ -0,0 +1,105 @@
1
+ import { BetterFetchError } from 'better-auth/react';
2
+ import { AuthClient } from '../../lib/auth-client';
3
+ export type SignUpEmailParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["signUp"]["email"]>[0];
4
+ export type SignUpEmailOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof signUpEmailOptions<TAuthClient>>, "mutationKey" | "mutationFn">;
5
+ /**
6
+ * Mutation options factory for email/password sign-up.
7
+ *
8
+ * @param authClient - The Better Auth client.
9
+ */
10
+ export declare function signUpEmailOptions<TAuthClient extends AuthClient>(authClient: TAuthClient): import('@tanstack/react-query').WithRequired<import('@tanstack/react-query').UseMutationOptions<(Omit<{
11
+ token: null;
12
+ user: {
13
+ id: string;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ email: string;
17
+ emailVerified: boolean;
18
+ name: string;
19
+ image?: string | null | undefined | undefined;
20
+ };
21
+ }, "user"> & {
22
+ user: import('better-auth').StripEmptyObjects<{
23
+ id: string;
24
+ createdAt: Date;
25
+ updatedAt: Date;
26
+ email: string;
27
+ emailVerified: boolean;
28
+ name: string;
29
+ image?: string | null | undefined;
30
+ }>;
31
+ }) | (Omit<{
32
+ token: string;
33
+ user: {
34
+ id: string;
35
+ createdAt: Date;
36
+ updatedAt: Date;
37
+ email: string;
38
+ emailVerified: boolean;
39
+ name: string;
40
+ image?: string | null | undefined | undefined;
41
+ };
42
+ }, "user"> & {
43
+ user: import('better-auth').StripEmptyObjects<{
44
+ id: string;
45
+ createdAt: Date;
46
+ updatedAt: Date;
47
+ email: string;
48
+ emailVerified: boolean;
49
+ name: string;
50
+ image?: string | null | undefined;
51
+ }>;
52
+ }), BetterFetchError, SignUpEmailParams<TAuthClient>, unknown>, "mutationKey">;
53
+ /**
54
+ * Create a mutation for email/password sign-up.
55
+ *
56
+ * Wraps `authClient.signUp.email`, resets the session query on success so
57
+ * the new session is refetched, and forwards React Query mutation options
58
+ * such as `onSuccess`, `onError`, and `retry`.
59
+ *
60
+ * @param authClient - The Better Auth client.
61
+ * @param options - React Query options forwarded to `useMutation`.
62
+ */
63
+ export declare function useSignUpEmail<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: SignUpEmailOptions<TAuthClient>): import('@tanstack/react-query').UseMutationResult<(Omit<{
64
+ token: null;
65
+ user: {
66
+ id: string;
67
+ createdAt: Date;
68
+ updatedAt: Date;
69
+ email: string;
70
+ emailVerified: boolean;
71
+ name: string;
72
+ image?: string | null | undefined | undefined;
73
+ };
74
+ }, "user"> & {
75
+ user: import('better-auth').StripEmptyObjects<{
76
+ id: string;
77
+ createdAt: Date;
78
+ updatedAt: Date;
79
+ email: string;
80
+ emailVerified: boolean;
81
+ name: string;
82
+ image?: string | null | undefined;
83
+ }>;
84
+ }) | (Omit<{
85
+ token: string;
86
+ user: {
87
+ id: string;
88
+ createdAt: Date;
89
+ updatedAt: Date;
90
+ email: string;
91
+ emailVerified: boolean;
92
+ name: string;
93
+ image?: string | null | undefined | undefined;
94
+ };
95
+ }, "user"> & {
96
+ user: import('better-auth').StripEmptyObjects<{
97
+ id: string;
98
+ createdAt: Date;
99
+ updatedAt: Date;
100
+ email: string;
101
+ emailVerified: boolean;
102
+ name: string;
103
+ image?: string | null | undefined;
104
+ }>;
105
+ }), BetterFetchError, SignUpEmailParams<TAuthClient>, unknown>;
@@ -0,0 +1,29 @@
1
+ import { sessionOptions as e } from "../../queries/auth/session-query.js";
2
+ import { authMutationKeys as t } from "@better-auth-ui/core";
3
+ import { mutationOptions as n, useMutation as r, useQueryClient as i } from "@tanstack/react-query";
4
+ //#region src/mutations/auth/sign-up-email-mutation.ts
5
+ function a(e) {
6
+ let r = t.signUp.email;
7
+ return n({
8
+ mutationKey: r,
9
+ mutationFn: (t) => e.signUp.email({
10
+ ...t,
11
+ fetchOptions: {
12
+ ...t?.fetchOptions,
13
+ throw: !0
14
+ }
15
+ })
16
+ });
17
+ }
18
+ function o(t, n) {
19
+ let o = i();
20
+ return r({
21
+ ...a(t),
22
+ ...n,
23
+ onSuccess: async (...r) => {
24
+ o.resetQueries({ queryKey: e(t).queryKey }), await n?.onSuccess?.(...r);
25
+ }
26
+ });
27
+ }
28
+ //#endregion
29
+ export { a as signUpEmailOptions, o as useSignUpEmail };
@@ -0,0 +1,42 @@
1
+ import { MutationKey, UseMutationOptions } from '@tanstack/react-query';
2
+ import { BetterFetchError } from 'better-auth/client';
3
+ /**
4
+ * Write-style Better Auth client method. Variables are a single object that
5
+ * may carry top-level params plus `fetchOptions` (e.g. `signIn.email` takes
6
+ * `{ email, password, rememberMe?, fetchOptions? }`).
7
+ *
8
+ * Read-style endpoints use `AuthQueryFn` / `useAuthQuery` instead.
9
+ */
10
+ export type AuthMutationFn = (variables: any) => Promise<unknown>;
11
+ /**
12
+ * Resolved data type returned by an {@link AuthMutationFn}.
13
+ */
14
+ export type AuthMutationFnData<TFn extends AuthMutationFn> = Awaited<ReturnType<TFn>>;
15
+ /**
16
+ * Variables type accepted by `mutate` / `mutateAsync` for a given
17
+ * {@link AuthMutationFn}.
18
+ *
19
+ * If the method's params are entirely optional (e.g. `authClient.signOut`),
20
+ * this resolves to `Variables | void` so `mutate()` is callable without
21
+ * arguments. Otherwise it resolves to the exact required shape so the type
22
+ * checker rejects `mutate()` when the underlying call needs params.
23
+ */
24
+ export type AuthMutationFnVariables<TFn extends AuthMutationFn> = Parameters<TFn>[0] extends infer P ? undefined extends P ? // biome-ignore lint/suspicious/noConfusingVoidType: void allows no-arg mutate
25
+ NonNullable<P> | void : P : never;
26
+ /**
27
+ * Return type of {@link authMutationOptions}, matching the shape produced by
28
+ * TanStack Query's own `mutationOptions` helper.
29
+ */
30
+ export type AuthMutationOptions<TFn extends AuthMutationFn, TMutationKey extends MutationKey = MutationKey> = Omit<UseMutationOptions<AuthMutationFnData<TFn>, BetterFetchError, AuthMutationFnVariables<TFn>>, "mutationKey"> & {
31
+ mutationKey: TMutationKey;
32
+ };
33
+ /**
34
+ * Build `mutationOptions` for a write-style Better Auth endpoint.
35
+ *
36
+ * Injects `throw: true` into `fetchOptions` so the promise rejects with a
37
+ * `BetterFetchError` on failure instead of resolving to `{ data, error }`.
38
+ *
39
+ * @param authFn - Better Auth client method (e.g. `authClient.emailOtp.sendVerificationOtp`).
40
+ * @param mutationKey - Stable key for the mutation (used by `useIsMutating`, `MutationCache`, …).
41
+ */
42
+ export declare function authMutationOptions<TFn extends AuthMutationFn, const TMutationKey extends MutationKey>(authFn: TFn, mutationKey: TMutationKey): AuthMutationOptions<TFn, TMutationKey>;