@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,60 @@
1
+ import { DataTag, QueryClient } from '@tanstack/react-query';
2
+ import { APIError } from 'better-auth';
3
+ import { MultiSessionAuthServer } from '../../../lib/auth-server';
4
+ export type ListDeviceSessionsData<TAuth extends MultiSessionAuthServer> = Awaited<ReturnType<TAuth["api"]["listDeviceSessions"]>>;
5
+ export type ListDeviceSession<TAuth extends MultiSessionAuthServer = MultiSessionAuthServer> = NonNullable<ListDeviceSessionsData<TAuth>>[number];
6
+ export type ListDeviceSessionsParams<TAuth extends MultiSessionAuthServer> = Parameters<TAuth["api"]["listDeviceSessions"]>[0];
7
+ /**
8
+ * Query options factory for the current user's device sessions.
9
+ *
10
+ * @param auth - The Better Auth server instance with the multi-session plugin.
11
+ * @param userId - The signed-in user's ID. Used for cache partitioning so
12
+ * the key matches the client-side `listDeviceSessionsOptions` for SSR hydration.
13
+ * @param params - Parameters forwarded to `auth.api.listDeviceSessions`.
14
+ */
15
+ export declare function listDeviceSessionsOptions<TAuth extends MultiSessionAuthServer>(auth: TAuth, userId: string, params: ListDeviceSessionsParams<TAuth>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Awaited<ReturnType<TAuth["api"]["listDeviceSessions"]>>, APIError, Awaited<ReturnType<TAuth["api"]["listDeviceSessions"]>>, readonly ["auth", "user", string | undefined, "listDeviceSessions", Record<string, any> | null]>, "queryFn"> & {
16
+ queryFn?: import('@tanstack/react-query').QueryFunction<Awaited<ReturnType<TAuth["api"]["listDeviceSessions"]>>, readonly ["auth", "user", string | undefined, "listDeviceSessions", Record<string, any> | null], never> | undefined;
17
+ } & {
18
+ queryKey: readonly ["auth", "user", string | undefined, "listDeviceSessions", Record<string, any> | null] & {
19
+ [dataTagSymbol]: Awaited<ReturnType<TAuth["api"]["listDeviceSessions"]>>;
20
+ [dataTagErrorSymbol]: APIError;
21
+ };
22
+ }) & {
23
+ queryKey: DataTag<readonly ["auth", "user", string | undefined, "listDeviceSessions", Record<string, any> | null], Awaited<ReturnType<TAuth["api"]["listDeviceSessions"]>>, APIError>;
24
+ };
25
+ /**
26
+ * Get the current user's device sessions from the query cache, calling
27
+ * `fetchListDeviceSessions` under the hood if no cached entry exists.
28
+ * Resolves with the device session list, making it suitable for reading
29
+ * directly in a server component.
30
+ *
31
+ * @param queryClient - The React Query client used for SSR hydration.
32
+ * @param auth - The Better Auth server instance with the multi-session plugin.
33
+ * @param userId - The signed-in user's ID, used for cache partitioning.
34
+ * @param params - Parameters forwarded to `auth.api.listDeviceSessions`.
35
+ */
36
+ export declare const ensureListDeviceSessions: <TAuth extends MultiSessionAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListDeviceSessionsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listDeviceSessions"]>>>;
37
+ /**
38
+ * Prefetch the current user's device sessions into the query cache. Behaves
39
+ * like `fetchListDeviceSessions`, but does not throw on error and does not
40
+ * return the data — use this when you only need the value to be available
41
+ * after hydration.
42
+ *
43
+ * @param queryClient - The React Query client used for SSR hydration.
44
+ * @param auth - The Better Auth server instance with the multi-session plugin.
45
+ * @param userId - The signed-in user's ID, used for cache partitioning.
46
+ * @param params - Parameters forwarded to `auth.api.listDeviceSessions`.
47
+ */
48
+ export declare const prefetchListDeviceSessions: <TAuth extends MultiSessionAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListDeviceSessionsParams<TAuth>) => Promise<void>;
49
+ /**
50
+ * Fetch and cache the current user's device sessions, resolving with the
51
+ * data or throwing on error. If a cached entry exists and is neither
52
+ * invalidated nor older than `staleTime`, the cached value is returned
53
+ * without a network call; otherwise the latest data is fetched.
54
+ *
55
+ * @param queryClient - The React Query client used for SSR hydration.
56
+ * @param auth - The Better Auth server instance with the multi-session plugin.
57
+ * @param userId - The signed-in user's ID, used for cache partitioning.
58
+ * @param params - Parameters forwarded to `auth.api.listDeviceSessions`.
59
+ */
60
+ export declare const fetchListDeviceSessions: <TAuth extends MultiSessionAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListDeviceSessionsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listDeviceSessions"]>>>;
@@ -0,0 +1,12 @@
1
+ import { authQueryKeys as e } from "@better-auth-ui/core";
2
+ import { queryOptions as t } from "@tanstack/react-query";
3
+ //#region src/server/queries/multi-session/list-device-sessions-query.ts
4
+ function n(n, r, i) {
5
+ return t({
6
+ queryKey: e.listDeviceSessions(r, i?.query),
7
+ queryFn: () => n.api.listDeviceSessions(i)
8
+ });
9
+ }
10
+ var r = (e, t, r, i) => e.ensureQueryData(n(t, r, i)), i = (e, t, r, i) => e.prefetchQuery(n(t, r, i)), a = (e, t, r, i) => e.fetchQuery(n(t, r, i));
11
+ //#endregion
12
+ export { r as ensureListDeviceSessions, a as fetchListDeviceSessions, n as listDeviceSessionsOptions, i as prefetchListDeviceSessions };
@@ -0,0 +1,60 @@
1
+ import { DataTag, QueryClient } from '@tanstack/react-query';
2
+ import { APIError } from 'better-auth';
3
+ import { PasskeyAuthServer } from '../../../lib/auth-server';
4
+ export type ListPasskeysData<TAuth extends PasskeyAuthServer> = Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>;
5
+ export type ListPasskeysParams<TAuth extends PasskeyAuthServer> = Parameters<TAuth["api"]["listPasskeys"]>[0];
6
+ export type ListPasskey<TAuth extends PasskeyAuthServer = PasskeyAuthServer> = NonNullable<ListPasskeysData<TAuth>>[number];
7
+ /**
8
+ * Query options factory for the current user's passkeys.
9
+ *
10
+ * @param auth - The Better Auth server instance with the passkey plugin.
11
+ * @param userId - The signed-in user's ID. Used for cache partitioning so
12
+ * the key matches the client-side `listPasskeysOptions` for SSR hydration.
13
+ * @param params - Parameters forwarded to `auth.api.listPasskeys`.
14
+ */
15
+ export declare function listPasskeysOptions<TAuth extends PasskeyAuthServer>(auth: TAuth, userId: string, params: ListPasskeysParams<TAuth>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>, APIError, Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>, readonly ["auth", "user", string | undefined, "listPasskeys", Record<string, any> | null]>, "queryFn"> & {
16
+ queryFn?: import('@tanstack/react-query').QueryFunction<Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>, readonly ["auth", "user", string | undefined, "listPasskeys", Record<string, any> | null], never> | undefined;
17
+ } & {
18
+ queryKey: readonly ["auth", "user", string | undefined, "listPasskeys", Record<string, any> | null] & {
19
+ [dataTagSymbol]: Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>;
20
+ [dataTagErrorSymbol]: APIError;
21
+ };
22
+ }) & {
23
+ queryKey: DataTag<readonly ["auth", "user", string | undefined, "listPasskeys", Record<string, any> | null], Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>, APIError>;
24
+ };
25
+ /**
26
+ * Get the current user's passkeys from the query cache, calling
27
+ * `fetchListPasskeys` under the hood if no cached entry exists. Resolves
28
+ * with the passkey list, making it suitable for reading directly in a server
29
+ * component.
30
+ *
31
+ * @param queryClient - The React Query client used for SSR hydration.
32
+ * @param auth - The Better Auth server instance with the passkey plugin.
33
+ * @param userId - The signed-in user's ID, used for cache partitioning.
34
+ * @param params - Parameters forwarded to `auth.api.listPasskeys`.
35
+ */
36
+ export declare const ensureListPasskeys: <TAuth extends PasskeyAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListPasskeysParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>>;
37
+ /**
38
+ * Prefetch the current user's passkeys into the query cache. Behaves like
39
+ * `fetchListPasskeys`, but does not throw on error and does not return
40
+ * the data — use this when you only need the value to be available after
41
+ * hydration.
42
+ *
43
+ * @param queryClient - The React Query client used for SSR hydration.
44
+ * @param auth - The Better Auth server instance with the passkey plugin.
45
+ * @param userId - The signed-in user's ID, used for cache partitioning.
46
+ * @param params - Parameters forwarded to `auth.api.listPasskeys`.
47
+ */
48
+ export declare const prefetchListPasskeys: <TAuth extends PasskeyAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListPasskeysParams<TAuth>) => Promise<void>;
49
+ /**
50
+ * Fetch and cache the current user's passkeys, resolving with the data or
51
+ * throwing on error. If a cached entry exists and is neither invalidated
52
+ * nor older than `staleTime`, the cached value is returned without a
53
+ * network call; otherwise the latest data is fetched.
54
+ *
55
+ * @param queryClient - The React Query client used for SSR hydration.
56
+ * @param auth - The Better Auth server instance with the passkey plugin.
57
+ * @param userId - The signed-in user's ID, used for cache partitioning.
58
+ * @param params - Parameters forwarded to `auth.api.listPasskeys`.
59
+ */
60
+ export declare const fetchListPasskeys: <TAuth extends PasskeyAuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListPasskeysParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listPasskeys"]>>>;
@@ -0,0 +1,12 @@
1
+ import { authQueryKeys as e } from "@better-auth-ui/core";
2
+ import { queryOptions as t } from "@tanstack/react-query";
3
+ //#region src/server/queries/passkey/list-passkeys-query.ts
4
+ function n(n, r, i) {
5
+ return t({
6
+ queryKey: e.listPasskeys(r, i?.query),
7
+ queryFn: () => n.api.listPasskeys(i)
8
+ });
9
+ }
10
+ var r = (e, t, r, i) => e.ensureQueryData(n(t, r, i)), i = (e, t, r, i) => e.prefetchQuery(n(t, r, i)), a = (e, t, r, i) => e.fetchQuery(n(t, r, i));
11
+ //#endregion
12
+ export { r as ensureListPasskeys, a as fetchListPasskeys, n as listPasskeysOptions, i as prefetchListPasskeys };
@@ -0,0 +1,68 @@
1
+ import { DataTag, QueryClient } from '@tanstack/react-query';
2
+ import { APIError } from 'better-auth';
3
+ import { AuthServer } from '../../../lib/auth-server';
4
+ export type AccountInfoData<TAuth extends AuthServer = AuthServer> = Awaited<ReturnType<TAuth["api"]["accountInfo"]>>;
5
+ export type AccountInfoParams<TAuth extends AuthServer> = Parameters<TAuth["api"]["accountInfo"]>[0];
6
+ export type AccountInfo<TAuth extends AuthServer = AuthServer> = NonNullable<AccountInfoData<TAuth>>;
7
+ /**
8
+ * Query options factory for provider-specific account info.
9
+ *
10
+ * @param auth - The Better Auth server instance.
11
+ * @param userId - The signed-in user's ID. Used for cache partitioning so
12
+ * the key matches the client-side `accountInfoOptions` for SSR hydration.
13
+ * @param params - Parameters forwarded to `auth.api.accountInfo`.
14
+ */
15
+ export declare function accountInfoOptions<TAuth extends AuthServer>(auth: TAuth, userId: string, params: AccountInfoParams<TAuth>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Awaited<ReturnType<TAuth["api"]["accountInfo"]>>, APIError, Awaited<ReturnType<TAuth["api"]["accountInfo"]>>, readonly ["auth", "user", string | undefined, "accountInfo", {
16
+ accountId?: string | undefined;
17
+ } | null]>, "queryFn"> & {
18
+ queryFn?: import('@tanstack/react-query').QueryFunction<Awaited<ReturnType<TAuth["api"]["accountInfo"]>>, readonly ["auth", "user", string | undefined, "accountInfo", {
19
+ accountId?: string | undefined;
20
+ } | null], never> | undefined;
21
+ } & {
22
+ queryKey: readonly ["auth", "user", string | undefined, "accountInfo", {
23
+ accountId?: string | undefined;
24
+ } | null] & {
25
+ [dataTagSymbol]: Awaited<ReturnType<TAuth["api"]["accountInfo"]>>;
26
+ [dataTagErrorSymbol]: APIError;
27
+ };
28
+ }) & {
29
+ queryKey: DataTag<readonly ["auth", "user", string | undefined, "accountInfo", {
30
+ accountId?: string | undefined;
31
+ } | null], Awaited<ReturnType<TAuth["api"]["accountInfo"]>>, APIError>;
32
+ };
33
+ /**
34
+ * Get the current user's provider-specific account info from the query
35
+ * cache, calling `fetchAccountInfo` under the hood if no cached entry
36
+ * exists. Resolves with the data, making it suitable for reading directly
37
+ * in a server component.
38
+ *
39
+ * @param queryClient - The React Query client used for SSR hydration.
40
+ * @param auth - The Better Auth server instance.
41
+ * @param userId - The signed-in user's ID, used for cache partitioning.
42
+ * @param params - Parameters forwarded to `auth.api.accountInfo`.
43
+ */
44
+ export declare const ensureAccountInfo: <TAuth extends AuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: AccountInfoParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["accountInfo"]>>>;
45
+ /**
46
+ * Prefetch the current user's provider-specific account info into the query
47
+ * cache. Behaves like `fetchAccountInfo`, but does not throw on error and
48
+ * does not return the data — use this when you only need the value to be
49
+ * available after hydration.
50
+ *
51
+ * @param queryClient - The React Query client used for SSR hydration.
52
+ * @param auth - The Better Auth server instance.
53
+ * @param userId - The signed-in user's ID, used for cache partitioning.
54
+ * @param params - Parameters forwarded to `auth.api.accountInfo`.
55
+ */
56
+ export declare const prefetchAccountInfo: <TAuth extends AuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: AccountInfoParams<TAuth>) => Promise<void>;
57
+ /**
58
+ * Fetch and cache the current user's provider-specific account info,
59
+ * resolving with the data or throwing on error. If a cached entry exists
60
+ * and is neither invalidated nor older than `staleTime`, the cached value
61
+ * is returned without a network call; otherwise the latest data is fetched.
62
+ *
63
+ * @param queryClient - The React Query client used for SSR hydration.
64
+ * @param auth - The Better Auth server instance.
65
+ * @param userId - The signed-in user's ID, used for cache partitioning.
66
+ * @param params - Parameters forwarded to `auth.api.accountInfo`.
67
+ */
68
+ export declare const fetchAccountInfo: <TAuth extends AuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: AccountInfoParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["accountInfo"]>>>;
@@ -0,0 +1,12 @@
1
+ import { authQueryKeys as e } from "@better-auth-ui/core";
2
+ import { queryOptions as t } from "@tanstack/react-query";
3
+ //#region src/server/queries/settings/account-info-query.ts
4
+ function n(n, r, i) {
5
+ return t({
6
+ queryKey: e.accountInfo(r, i?.query),
7
+ queryFn: () => n.api.accountInfo(i)
8
+ });
9
+ }
10
+ var r = (e, t, r, i) => e.ensureQueryData(n(t, r, i)), i = (e, t, r, i) => e.prefetchQuery(n(t, r, i)), a = (e, t, r, i) => e.fetchQuery(n(t, r, i));
11
+ //#endregion
12
+ export { n as accountInfoOptions, r as ensureAccountInfo, a as fetchAccountInfo, i as prefetchAccountInfo };
@@ -0,0 +1,60 @@
1
+ import { DataTag, QueryClient } from '@tanstack/react-query';
2
+ import { APIError } from 'better-auth';
3
+ import { AuthServer } from '../../../lib/auth-server';
4
+ export type ListAccountsData<TAuth extends AuthServer = AuthServer> = Awaited<ReturnType<TAuth["api"]["listUserAccounts"]>>;
5
+ export type ListAccountsParams<TAuth extends AuthServer> = Parameters<TAuth["api"]["listUserAccounts"]>[0];
6
+ export type ListAccount<TAuth extends AuthServer = AuthServer> = NonNullable<ListAccountsData<TAuth>>[number];
7
+ /**
8
+ * Query options factory for the current user's linked social accounts.
9
+ *
10
+ * @param auth - The Better Auth server instance.
11
+ * @param userId - The signed-in user's ID. Used for cache partitioning so
12
+ * the key matches the client-side `listAccountsOptions` for SSR hydration.
13
+ * @param params - Parameters forwarded to `auth.api.listUserAccounts`.
14
+ */
15
+ export declare function listAccountsOptions<TAuth extends AuthServer>(auth: TAuth, userId: string, params: ListAccountsParams<TAuth>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Awaited<ReturnType<TAuth["api"]["listUserAccounts"]>>, APIError, Awaited<ReturnType<TAuth["api"]["listUserAccounts"]>>, readonly ["auth", "user", string | undefined, "listAccounts", Record<string, any> | null]>, "queryFn"> & {
16
+ queryFn?: import('@tanstack/react-query').QueryFunction<Awaited<ReturnType<TAuth["api"]["listUserAccounts"]>>, readonly ["auth", "user", string | undefined, "listAccounts", Record<string, any> | null], never> | undefined;
17
+ } & {
18
+ queryKey: readonly ["auth", "user", string | undefined, "listAccounts", Record<string, any> | null] & {
19
+ [dataTagSymbol]: Awaited<ReturnType<TAuth["api"]["listUserAccounts"]>>;
20
+ [dataTagErrorSymbol]: APIError;
21
+ };
22
+ }) & {
23
+ queryKey: DataTag<readonly ["auth", "user", string | undefined, "listAccounts", Record<string, any> | null], Awaited<ReturnType<TAuth["api"]["listUserAccounts"]>>, APIError>;
24
+ };
25
+ /**
26
+ * Get the current user's linked social accounts from the query cache,
27
+ * calling `fetchListAccounts` under the hood if no cached entry exists.
28
+ * Resolves with the account list, making it suitable for reading directly
29
+ * in a server component.
30
+ *
31
+ * @param queryClient - The React Query client used for SSR hydration.
32
+ * @param auth - The Better Auth server instance.
33
+ * @param userId - The signed-in user's ID, used for cache partitioning.
34
+ * @param params - Parameters forwarded to `auth.api.listUserAccounts`.
35
+ */
36
+ export declare const ensureListAccounts: <TAuth extends AuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListAccountsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listUserAccounts"]>>>;
37
+ /**
38
+ * Prefetch the current user's linked social accounts into the query cache.
39
+ * Behaves like `fetchListAccounts`, but does not throw on error and does
40
+ * not return the data — use this when you only need the value to be
41
+ * available after hydration.
42
+ *
43
+ * @param queryClient - The React Query client used for SSR hydration.
44
+ * @param auth - The Better Auth server instance.
45
+ * @param userId - The signed-in user's ID, used for cache partitioning.
46
+ * @param params - Parameters forwarded to `auth.api.listUserAccounts`.
47
+ */
48
+ export declare const prefetchListAccounts: <TAuth extends AuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListAccountsParams<TAuth>) => Promise<void>;
49
+ /**
50
+ * Fetch and cache the current user's linked social accounts, resolving
51
+ * with the data or throwing on error. If a cached entry exists and is
52
+ * neither invalidated nor older than `staleTime`, the cached value is
53
+ * returned without a network call; otherwise the latest data is fetched.
54
+ *
55
+ * @param queryClient - The React Query client used for SSR hydration.
56
+ * @param auth - The Better Auth server instance.
57
+ * @param userId - The signed-in user's ID, used for cache partitioning.
58
+ * @param params - Parameters forwarded to `auth.api.listUserAccounts`.
59
+ */
60
+ export declare const fetchListAccounts: <TAuth extends AuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListAccountsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listUserAccounts"]>>>;
@@ -0,0 +1,12 @@
1
+ import { authQueryKeys as e } from "@better-auth-ui/core";
2
+ import { queryOptions as t } from "@tanstack/react-query";
3
+ //#region src/server/queries/settings/list-accounts-query.ts
4
+ function n(n, r, i) {
5
+ return t({
6
+ queryKey: e.listAccounts(r, i?.query),
7
+ queryFn: () => n.api.listUserAccounts(i)
8
+ });
9
+ }
10
+ var r = (e, t, r, i) => e.ensureQueryData(n(t, r, i)), i = (e, t, r, i) => e.prefetchQuery(n(t, r, i)), a = (e, t, r, i) => e.fetchQuery(n(t, r, i));
11
+ //#endregion
12
+ export { r as ensureListAccounts, a as fetchListAccounts, n as listAccountsOptions, i as prefetchListAccounts };
@@ -0,0 +1,60 @@
1
+ import { DataTag, QueryClient } from '@tanstack/react-query';
2
+ import { APIError } from 'better-auth';
3
+ import { AuthServer } from '../../../lib/auth-server';
4
+ export type ListSessionsData<TAuth extends AuthServer = AuthServer> = Awaited<ReturnType<TAuth["api"]["listSessions"]>>;
5
+ export type ListSessionsParams<TAuth extends AuthServer> = Parameters<TAuth["api"]["listSessions"]>[0];
6
+ export type ListSession<TAuth extends AuthServer = AuthServer> = NonNullable<ListSessionsData<TAuth>>[number];
7
+ /**
8
+ * Query options factory for the current user's active sessions.
9
+ *
10
+ * @param auth - The Better Auth server instance.
11
+ * @param userId - The signed-in user's ID. Used for cache partitioning so
12
+ * the key matches the client-side `listSessionsOptions` for SSR hydration.
13
+ * @param params - Parameters forwarded to `auth.api.listSessions`.
14
+ */
15
+ export declare function listSessionsOptions<TAuth extends AuthServer>(auth: TAuth, userId: string, params: ListSessionsParams<TAuth>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<Awaited<ReturnType<TAuth["api"]["listSessions"]>>, APIError, Awaited<ReturnType<TAuth["api"]["listSessions"]>>, readonly ["auth", "user", string | undefined, "listSessions", Record<string, any> | null]>, "queryFn"> & {
16
+ queryFn?: import('@tanstack/react-query').QueryFunction<Awaited<ReturnType<TAuth["api"]["listSessions"]>>, readonly ["auth", "user", string | undefined, "listSessions", Record<string, any> | null], never> | undefined;
17
+ } & {
18
+ queryKey: readonly ["auth", "user", string | undefined, "listSessions", Record<string, any> | null] & {
19
+ [dataTagSymbol]: Awaited<ReturnType<TAuth["api"]["listSessions"]>>;
20
+ [dataTagErrorSymbol]: APIError;
21
+ };
22
+ }) & {
23
+ queryKey: DataTag<readonly ["auth", "user", string | undefined, "listSessions", Record<string, any> | null], Awaited<ReturnType<TAuth["api"]["listSessions"]>>, APIError>;
24
+ };
25
+ /**
26
+ * Get the current user's active sessions from the query cache, calling
27
+ * `fetchListSessions` under the hood if no cached entry exists. Resolves
28
+ * with the session list, making it suitable for reading directly in a server
29
+ * component.
30
+ *
31
+ * @param queryClient - The React Query client used for SSR hydration.
32
+ * @param auth - The Better Auth server instance.
33
+ * @param userId - The signed-in user's ID, used for cache partitioning.
34
+ * @param params - Parameters forwarded to `auth.api.listSessions`.
35
+ */
36
+ export declare const ensureListSessions: <TAuth extends AuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListSessionsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listSessions"]>>>;
37
+ /**
38
+ * Prefetch the current user's active sessions into the query cache. Behaves
39
+ * like `fetchListSessions`, but does not throw on error and does not return
40
+ * the data — use this when you only need the value to be available after
41
+ * hydration.
42
+ *
43
+ * @param queryClient - The React Query client used for SSR hydration.
44
+ * @param auth - The Better Auth server instance.
45
+ * @param userId - The signed-in user's ID, used for cache partitioning.
46
+ * @param params - Parameters forwarded to `auth.api.listSessions`.
47
+ */
48
+ export declare const prefetchListSessions: <TAuth extends AuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListSessionsParams<TAuth>) => Promise<void>;
49
+ /**
50
+ * Fetch and cache the current user's active sessions, resolving with the
51
+ * data or throwing on error. If a cached entry exists and is neither
52
+ * invalidated nor older than `staleTime`, the cached value is returned
53
+ * without a network call; otherwise the latest data is fetched.
54
+ *
55
+ * @param queryClient - The React Query client used for SSR hydration.
56
+ * @param auth - The Better Auth server instance.
57
+ * @param userId - The signed-in user's ID, used for cache partitioning.
58
+ * @param params - Parameters forwarded to `auth.api.listSessions`.
59
+ */
60
+ export declare const fetchListSessions: <TAuth extends AuthServer>(queryClient: QueryClient, auth: TAuth, userId: string, params: ListSessionsParams<TAuth>) => Promise<Awaited<ReturnType<TAuth["api"]["listSessions"]>>>;
@@ -0,0 +1,12 @@
1
+ import { authQueryKeys as e } from "@better-auth-ui/core";
2
+ import { queryOptions as t } from "@tanstack/react-query";
3
+ //#region src/server/queries/settings/list-sessions-query.ts
4
+ function n(n, r, i) {
5
+ return t({
6
+ queryKey: e.listSessions(r, i?.query),
7
+ queryFn: () => n.api.listSessions(i)
8
+ });
9
+ }
10
+ var r = (e, t, r, i) => e.ensureQueryData(n(t, r, i)), i = (e, t, r, i) => e.prefetchQuery(n(t, r, i)), a = (e, t, r, i) => e.fetchQuery(n(t, r, i));
11
+ //#endregion
12
+ export { r as ensureListSessions, a as fetchListSessions, n as listSessionsOptions, i as prefetchListSessions };
@@ -0,0 +1,7 @@
1
+ export type * from './lib/auth-server';
2
+ export * from './server/queries/auth/session-query';
3
+ export * from './server/queries/multi-session/list-device-sessions-query';
4
+ export * from './server/queries/passkey/list-passkeys-query';
5
+ export * from './server/queries/settings/account-info-query';
6
+ export * from './server/queries/settings/list-accounts-query';
7
+ export * from './server/queries/settings/list-sessions-query';
package/dist/server.js ADDED
@@ -0,0 +1,7 @@
1
+ import { ensureSession as e, fetchSession as t, prefetchSession as n, sessionOptions as r } from "./server/queries/auth/session-query.js";
2
+ import { ensureListDeviceSessions as i, fetchListDeviceSessions as a, listDeviceSessionsOptions as o, prefetchListDeviceSessions as s } from "./server/queries/multi-session/list-device-sessions-query.js";
3
+ import { ensureListPasskeys as c, fetchListPasskeys as l, listPasskeysOptions as u, prefetchListPasskeys as d } from "./server/queries/passkey/list-passkeys-query.js";
4
+ import { accountInfoOptions as f, ensureAccountInfo as p, fetchAccountInfo as m, prefetchAccountInfo as h } from "./server/queries/settings/account-info-query.js";
5
+ import { ensureListAccounts as g, fetchListAccounts as _, listAccountsOptions as v, prefetchListAccounts as y } from "./server/queries/settings/list-accounts-query.js";
6
+ import { ensureListSessions as b, fetchListSessions as x, listSessionsOptions as S, prefetchListSessions as C } from "./server/queries/settings/list-sessions-query.js";
7
+ export { f as accountInfoOptions, p as ensureAccountInfo, g as ensureListAccounts, i as ensureListDeviceSessions, c as ensureListPasskeys, b as ensureListSessions, e as ensureSession, m as fetchAccountInfo, _ as fetchListAccounts, a as fetchListDeviceSessions, l as fetchListPasskeys, x as fetchListSessions, t as fetchSession, v as listAccountsOptions, o as listDeviceSessionsOptions, u as listPasskeysOptions, S as listSessionsOptions, h as prefetchAccountInfo, y as prefetchListAccounts, s as prefetchListDeviceSessions, d as prefetchListPasskeys, C as prefetchListSessions, n as prefetchSession, r as sessionOptions };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@better-auth-ui/react",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",
7
- "dev": "tsc --watch",
8
- "email": "email dev --dir src/components/email -p 9000",
7
+ "dev": "vite build --watch",
8
+ "email": "email dev --dir src/components/auth/email -p 9000",
9
9
  "test": "vitest"
10
10
  },
11
11
  "files": [
@@ -19,46 +19,48 @@
19
19
  "types": "./dist/index.d.ts",
20
20
  "import": "./dist/index.js"
21
21
  },
22
- "./core": {
23
- "types": "./dist/core.d.ts",
24
- "import": "./dist/core.js"
22
+ "./email": {
23
+ "types": "./dist/email.d.ts",
24
+ "import": "./dist/email.js"
25
+ },
26
+ "./server": {
27
+ "types": "./dist/server.d.ts",
28
+ "import": "./dist/server.js"
25
29
  }
26
30
  },
27
31
  "devDependencies": {
32
+ "@better-auth/passkey": "^1.6.9",
28
33
  "@react-email/components": "^1.0.12",
29
34
  "@react-email/preview-server": "^5.2.10",
30
- "@tanstack/react-query": "^5.99.0",
35
+ "@tanstack/react-query": "^5.100.8",
31
36
  "@testing-library/react": "^16.3.2",
32
37
  "@testing-library/user-event": "^14.5.2",
33
38
  "@types/react": "^19.2.14",
34
39
  "@vitejs/plugin-react": "^6.0.1",
35
- "@vitest/browser-playwright": "^4.1.4",
36
- "@better-auth/passkey": "^1.6.5",
37
- "better-auth": "^1.6.5",
40
+ "@vitest/browser-playwright": "^4.1.5",
41
+ "better-auth": "^1.6.9",
38
42
  "clsx": "^2.1.1",
39
43
  "playwright": "^1.59.1",
40
44
  "react": "^19.2.5",
41
45
  "react-dom": "^19.2.5",
42
- "react-email": "^6.0.0",
46
+ "react-email": "^6.0.5",
43
47
  "tailwind-merge": "^3.5.0",
44
- "tailwindcss": "^4.2.2",
45
- "vitest": "^4.1.4",
46
- "zod": "^4.3.6"
47
- },
48
- "dependencies": {
49
- "@better-auth-ui/core": "*"
48
+ "tailwindcss": "^4.2.4",
49
+ "vitest": "^4.1.5",
50
+ "zod": "^4.4.2"
50
51
  },
51
52
  "peerDependencies": {
53
+ "@better-auth-ui/core": "*",
54
+ "@better-auth/passkey": ">=1.6.9",
52
55
  "@react-email/components": ">=1.0.12",
53
- "@tanstack/react-query": ">=5.99.0",
54
- "@better-auth/passkey": ">=1.6.5",
55
- "better-auth": ">=1.6.5",
56
+ "@tanstack/react-query": ">=5.100.8",
57
+ "better-auth": ">=1.6.9",
56
58
  "clsx": ">=2.0.0",
57
59
  "react": ">=19.2.5",
58
60
  "react-dom": ">=19.2.5",
59
61
  "tailwind-merge": ">=3.5.0",
60
- "tailwindcss": ">=4.2.2",
61
- "zod": ">=4.3.0"
62
+ "tailwindcss": ">=4.2.4",
63
+ "zod": ">=4.4.2"
62
64
  },
63
65
  "repository": {
64
66
  "type": "git",
@@ -1,30 +1,57 @@
1
1
  "use client"
2
2
 
3
- import { deepmerge, defaultAuthConfig } from "@better-auth-ui/core"
3
+ import {
4
+ type AdditionalField,
5
+ type AuthConfig,
6
+ type DeepPartial,
7
+ deepmerge,
8
+ defaultAuthConfig
9
+ } from "@better-auth-ui/core"
4
10
  import {
5
11
  QueryClient,
6
12
  QueryClientContext,
7
13
  QueryClientProvider
8
14
  } from "@tanstack/react-query"
9
- import { type PropsWithChildren, useContext } from "react"
15
+ import {
16
+ createContext,
17
+ type PropsWithChildren,
18
+ type ReactNode,
19
+ useContext
20
+ } from "react"
10
21
 
11
- import type { AnyAuthClient } from "../../lib/auth-client"
12
- import type { AnyAuthConfig, AuthConfig } from "../../lib/auth-config"
13
- import { AuthContext } from "../../lib/auth-context"
22
+ import type { AuthClient } from "../../lib/auth-client"
14
23
 
15
- const fallbackQueryClient = new QueryClient()
24
+ const AuthContext = createContext<AuthConfig | undefined>(undefined)
16
25
 
17
- const baseAuthConfig: AnyAuthConfig = {
18
- ...defaultAuthConfig,
19
- Link: (props) => <a {...props} />
26
+ const fallbackQueryClient = new QueryClient({
27
+ defaultOptions: {
28
+ queries: {
29
+ staleTime: 5000
30
+ }
31
+ }
32
+ })
33
+
34
+ declare module "@better-auth-ui/core" {
35
+ interface AuthConfig {
36
+ /**
37
+ * The auth client to use for the authentication context.
38
+ * @remarks `AuthClient`
39
+ */
40
+ authClient: AuthClient
41
+ }
42
+
43
+ /** Widen `AdditionalField.label` to `ReactNode` in the React package. */
44
+ interface AdditionalFieldRegister {
45
+ label: ReactNode
46
+ }
20
47
  }
21
48
 
22
- export type AuthProviderProps = PropsWithChildren<AnyAuthConfig> & {
23
- authClient: AnyAuthClient
49
+ export type AuthProviderProps<TAuthClient = AuthClient> = PropsWithChildren<
50
+ DeepPartial<AuthConfig>
51
+ > & {
52
+ authClient: TAuthClient
24
53
  navigate: (options: { to: string; replace?: boolean }) => void
25
- /**
26
- * TanStack QueryClient to use for your application's queries
27
- */
54
+ /** TanStack QueryClient to use for your application's queries */
28
55
  queryClient?: QueryClient
29
56
  }
30
57
 
@@ -43,33 +70,69 @@ export function AuthProvider({
43
70
  queryClient,
44
71
  ...config
45
72
  }: AuthProviderProps) {
46
- const contextQueryClient = useContext(QueryClientContext)
47
- const resolvedQueryClient =
48
- queryClient || contextQueryClient || fallbackQueryClient
49
-
50
- const mergedConfig = deepmerge(baseAuthConfig, config) as AuthConfig
73
+ const mergedConfig = deepmerge(defaultAuthConfig, {
74
+ ...config,
75
+ viewPaths: {
76
+ auth: {
77
+ ...defaultAuthConfig.viewPaths.auth,
78
+ ...config.viewPaths?.auth
79
+ },
80
+ settings: {
81
+ ...defaultAuthConfig.viewPaths.settings,
82
+ ...config.viewPaths?.settings
83
+ }
84
+ }
85
+ } as AuthConfig)
51
86
 
52
87
  mergedConfig.redirectTo =
53
88
  (typeof window !== "undefined" &&
54
89
  new URLSearchParams(window.location.search).get("redirectTo")?.trim()) ||
55
90
  mergedConfig.redirectTo
56
91
 
92
+ // Merge plugin-contributed `additionalFields` with user-supplied ones.
93
+ // Plugin order is preserved; user-supplied entries with the same `name`
94
+ // override the plugin contribution.
95
+ const fieldsByName = new Map<string, AdditionalField>()
96
+ for (const plugin of mergedConfig.plugins ?? []) {
97
+ for (const field of plugin.additionalFields ?? []) {
98
+ fieldsByName.set(field.name, field)
99
+ }
100
+ }
101
+ for (const field of mergedConfig.additionalFields ?? []) {
102
+ fieldsByName.set(field.name, field)
103
+ }
104
+ mergedConfig.additionalFields = Array.from(fieldsByName.values())
105
+
106
+ const contextQueryClient = useContext(QueryClientContext)
107
+
108
+ if (contextQueryClient) {
109
+ return (
110
+ <AuthContext.Provider value={mergedConfig}>
111
+ {children}
112
+ </AuthContext.Provider>
113
+ )
114
+ }
115
+
57
116
  return (
58
- <AuthContext.Provider value={mergedConfig}>
59
- <QueryClientProvider client={resolvedQueryClient}>
117
+ <QueryClientProvider client={queryClient || fallbackQueryClient}>
118
+ <AuthContext.Provider value={mergedConfig}>
60
119
  {children}
61
- </QueryClientProvider>
62
- </AuthContext.Provider>
120
+ </AuthContext.Provider>
121
+ </QueryClientProvider>
63
122
  )
64
123
  }
65
124
 
66
125
  /**
67
126
  * Accesses the current authentication configuration from AuthContext.
68
127
  *
128
+ * UI packages widen the plugin type globally via the `Register` interface
129
+ * (see module augmentation in `@better-auth-ui/heroui`), so callers don't
130
+ * need to pass a generic.
131
+ *
69
132
  * @returns The merged authentication configuration provided by AuthProvider.
70
133
  * @throws If no AuthProvider is present in the component tree.
71
134
  */
72
- export function useAuth() {
135
+ export function useAuth(): AuthConfig {
73
136
  const context = useContext(AuthContext)
74
137
 
75
138
  if (!context) {