@better-auth-ui/react 1.6.3 → 1.6.5

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 (355) hide show
  1. package/dist/components/auth/auth-provider.d.ts +23 -8
  2. package/dist/components/auth/auth-provider.js +35 -19
  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/components/auth/fetch-options-provider.d.ts +19 -0
  13. package/dist/components/auth/fetch-options-provider.js +30 -0
  14. package/dist/email.d.ts +1 -0
  15. package/dist/email.js +11 -0
  16. package/dist/hooks/auth/use-authenticate.d.ts +5 -28
  17. package/dist/hooks/auth/use-authenticate.js +12 -12
  18. package/dist/hooks/auth/use-user.d.ts +19 -314
  19. package/dist/hooks/auth/use-user.js +5 -5
  20. package/dist/hooks/use-auth-mutation.d.ts +12 -7
  21. package/dist/hooks/use-auth-plugin.d.ts +31 -0
  22. package/dist/hooks/use-auth-plugin.js +10 -0
  23. package/dist/hooks/use-auth-query.d.ts +3 -3
  24. package/dist/index.d.ts +34 -32
  25. package/dist/index.js +75 -83
  26. package/dist/lib/auth-client.d.ts +23 -3687
  27. package/dist/lib/auth-plugin.d.ts +61 -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 +37 -20
  44. package/dist/mutations/auth-mutation-options.js +2 -2
  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/plugins/captcha-plugin.d.ts +29 -0
  76. package/dist/plugins/captcha-plugin.js +29 -0
  77. package/dist/plugins.d.ts +1 -0
  78. package/dist/plugins.js +3 -0
  79. package/dist/queries/auth/session-query.d.ts +71 -0
  80. package/dist/queries/auth/session-query.js +30 -0
  81. package/dist/queries/auth-query-options.d.ts +26 -15
  82. package/dist/queries/multi-session/list-device-sessions-query.d.ts +76 -0
  83. package/dist/queries/multi-session/list-device-sessions-query.js +31 -0
  84. package/dist/queries/passkey/list-passkeys-query.d.ts +74 -0
  85. package/dist/queries/passkey/list-passkeys-query.js +31 -0
  86. package/dist/queries/settings/account-info-query.d.ts +85 -0
  87. package/dist/queries/settings/account-info-query.js +31 -0
  88. package/dist/queries/settings/list-accounts-query.d.ts +76 -0
  89. package/dist/queries/settings/list-accounts-query.js +31 -0
  90. package/dist/queries/settings/list-sessions-query.d.ts +74 -0
  91. package/dist/queries/settings/list-sessions-query.js +31 -0
  92. package/dist/server/queries/auth/session-query.d.ts +57 -0
  93. package/dist/server/queries/auth/session-query.js +13 -0
  94. package/dist/server/queries/multi-session/list-device-sessions-query.d.ts +60 -0
  95. package/dist/server/queries/multi-session/list-device-sessions-query.js +12 -0
  96. package/dist/server/queries/passkey/list-passkeys-query.d.ts +60 -0
  97. package/dist/server/queries/passkey/list-passkeys-query.js +12 -0
  98. package/dist/server/queries/settings/account-info-query.d.ts +68 -0
  99. package/dist/server/queries/settings/account-info-query.js +12 -0
  100. package/dist/server/queries/settings/list-accounts-query.d.ts +60 -0
  101. package/dist/server/queries/settings/list-accounts-query.js +12 -0
  102. package/dist/server/queries/settings/list-sessions-query.d.ts +60 -0
  103. package/dist/server/queries/settings/list-sessions-query.js +12 -0
  104. package/dist/server.d.ts +7 -0
  105. package/dist/server.js +7 -0
  106. package/package.json +28 -22
  107. package/src/components/auth/auth-provider.tsx +88 -25
  108. package/src/components/{email → auth/email}/email-changed.tsx +1 -1
  109. package/src/components/{email → auth/email}/email-verification.tsx +1 -1
  110. package/src/components/{email → auth/email}/magic-link.tsx +1 -1
  111. package/src/components/{email → auth/email}/new-device.tsx +1 -1
  112. package/src/components/{email → auth/email}/otp-email.tsx +1 -1
  113. package/src/components/{email → auth/email}/password-changed.tsx +1 -1
  114. package/src/components/{email → auth/email}/reset-password.tsx +1 -1
  115. package/src/components/auth/fetch-options-provider.tsx +77 -0
  116. package/src/email.ts +1 -0
  117. package/src/hooks/auth/use-authenticate.ts +12 -6
  118. package/src/hooks/auth/use-user.ts +14 -9
  119. package/src/hooks/use-auth-mutation.ts +30 -12
  120. package/src/hooks/use-auth-plugin.ts +50 -0
  121. package/src/hooks/use-auth-query.ts +11 -7
  122. package/src/index.ts +34 -32
  123. package/src/lib/auth-client.ts +33 -31
  124. package/src/lib/auth-plugin.ts +77 -0
  125. package/src/lib/auth-server.ts +30 -0
  126. package/src/mutations/auth/request-password-reset-mutation.ts +58 -0
  127. package/src/mutations/auth/reset-password-mutation.ts +60 -0
  128. package/src/mutations/auth/send-verification-email-mutation.ts +58 -0
  129. package/src/mutations/auth/sign-in-email-mutation.ts +78 -0
  130. package/src/mutations/auth/sign-in-social-mutation.ts +64 -0
  131. package/src/mutations/auth/sign-out-mutation.ts +71 -0
  132. package/src/mutations/auth/sign-up-email-mutation.ts +74 -0
  133. package/src/mutations/auth-mutation-options.ts +83 -38
  134. package/src/mutations/magic-link/sign-in-magic-link-mutation.ts +59 -0
  135. package/src/mutations/multi-session/revoke-multi-session-mutation.ts +70 -0
  136. package/src/mutations/multi-session/set-active-session-mutation.ts +98 -0
  137. package/src/mutations/passkey/add-passkey-mutation.ts +66 -0
  138. package/src/mutations/passkey/delete-passkey-mutation.ts +66 -0
  139. package/src/mutations/passkey/sign-in-passkey-mutation.ts +74 -0
  140. package/src/mutations/settings/change-email-mutation.ts +67 -0
  141. package/src/mutations/settings/change-password-mutation.ts +59 -0
  142. package/src/mutations/settings/delete-user-mutation.ts +59 -0
  143. package/src/mutations/settings/link-social-mutation.ts +59 -0
  144. package/src/mutations/settings/revoke-session-mutation.ts +69 -0
  145. package/src/mutations/settings/unlink-account-mutation.ts +67 -0
  146. package/src/mutations/settings/update-user-mutation.ts +82 -0
  147. package/src/mutations/username/is-username-available-mutation.ts +62 -0
  148. package/src/mutations/username/sign-in-username-mutation.ts +74 -0
  149. package/src/plugins/captcha-plugin.tsx +75 -0
  150. package/src/plugins.ts +3 -0
  151. package/src/queries/auth/session-query.ts +135 -0
  152. package/src/queries/auth-query-options.ts +61 -12
  153. package/src/queries/multi-session/list-device-sessions-query.ts +177 -0
  154. package/src/queries/passkey/list-passkeys-query.ts +154 -0
  155. package/src/queries/settings/account-info-query.ts +158 -0
  156. package/src/queries/settings/list-accounts-query.ts +156 -0
  157. package/src/queries/settings/list-sessions-query.ts +154 -0
  158. package/src/server/queries/auth/session-query.ts +94 -0
  159. package/src/server/queries/multi-session/list-device-sessions-query.ts +102 -0
  160. package/src/server/queries/passkey/list-passkeys-query.ts +100 -0
  161. package/src/server/queries/settings/account-info-query.ts +101 -0
  162. package/src/server/queries/settings/list-accounts-query.ts +101 -0
  163. package/src/server/queries/settings/list-sessions-query.ts +101 -0
  164. package/src/server.ts +7 -0
  165. package/dist/core.d.ts +0 -1
  166. package/dist/core.js +0 -1
  167. package/dist/hooks/auth/use-is-username-available.d.ts +0 -20
  168. package/dist/hooks/auth/use-is-username-available.js +0 -13
  169. package/dist/hooks/auth/use-request-password-reset.d.ts +0 -21
  170. package/dist/hooks/auth/use-request-password-reset.js +0 -13
  171. package/dist/hooks/auth/use-reset-password.d.ts +0 -23
  172. package/dist/hooks/auth/use-reset-password.js +0 -13
  173. package/dist/hooks/auth/use-send-verification-email.d.ts +0 -19
  174. package/dist/hooks/auth/use-send-verification-email.js +0 -13
  175. package/dist/hooks/auth/use-session.d.ts +0 -35
  176. package/dist/hooks/auth/use-session.js +0 -16
  177. package/dist/hooks/auth/use-sign-in-email.d.ts +0 -26
  178. package/dist/hooks/auth/use-sign-in-email.js +0 -17
  179. package/dist/hooks/auth/use-sign-in-magic-link.d.ts +0 -27
  180. package/dist/hooks/auth/use-sign-in-magic-link.js +0 -13
  181. package/dist/hooks/auth/use-sign-in-passkey.d.ts +0 -21
  182. package/dist/hooks/auth/use-sign-in-passkey.js +0 -17
  183. package/dist/hooks/auth/use-sign-in-social.d.ts +0 -63
  184. package/dist/hooks/auth/use-sign-in-social.js +0 -13
  185. package/dist/hooks/auth/use-sign-in-username.d.ts +0 -25
  186. package/dist/hooks/auth/use-sign-in-username.js +0 -17
  187. package/dist/hooks/auth/use-sign-out.d.ts +0 -18
  188. package/dist/hooks/auth/use-sign-out.js +0 -16
  189. package/dist/hooks/auth/use-sign-up-email.d.ts +0 -1186
  190. package/dist/hooks/auth/use-sign-up-email.js +0 -17
  191. package/dist/hooks/settings/use-account-info.d.ts +0 -17
  192. package/dist/hooks/settings/use-account-info.js +0 -18
  193. package/dist/hooks/settings/use-add-passkey.d.ts +0 -21
  194. package/dist/hooks/settings/use-add-passkey.js +0 -17
  195. package/dist/hooks/settings/use-change-email.d.ts +0 -21
  196. package/dist/hooks/settings/use-change-email.js +0 -17
  197. package/dist/hooks/settings/use-change-password.d.ts +0 -21
  198. package/dist/hooks/settings/use-change-password.js +0 -13
  199. package/dist/hooks/settings/use-delete-passkey.d.ts +0 -19
  200. package/dist/hooks/settings/use-delete-passkey.js +0 -17
  201. package/dist/hooks/settings/use-delete-user.d.ts +0 -24
  202. package/dist/hooks/settings/use-delete-user.js +0 -13
  203. package/dist/hooks/settings/use-link-social.d.ts +0 -43
  204. package/dist/hooks/settings/use-link-social.js +0 -13
  205. package/dist/hooks/settings/use-list-accounts.d.ts +0 -22
  206. package/dist/hooks/settings/use-list-accounts.js +0 -15
  207. package/dist/hooks/settings/use-list-device-sessions.d.ts +0 -34
  208. package/dist/hooks/settings/use-list-device-sessions.js +0 -15
  209. package/dist/hooks/settings/use-list-sessions.d.ts +0 -23
  210. package/dist/hooks/settings/use-list-sessions.js +0 -15
  211. package/dist/hooks/settings/use-list-user-passkeys.d.ts +0 -14
  212. package/dist/hooks/settings/use-list-user-passkeys.js +0 -15
  213. package/dist/hooks/settings/use-revoke-multi-session.d.ts +0 -19
  214. package/dist/hooks/settings/use-revoke-multi-session.js +0 -17
  215. package/dist/hooks/settings/use-revoke-session.d.ts +0 -19
  216. package/dist/hooks/settings/use-revoke-session.js +0 -17
  217. package/dist/hooks/settings/use-set-active-session.d.ts +0 -20
  218. package/dist/hooks/settings/use-set-active-session.js +0 -20
  219. package/dist/hooks/settings/use-unlink-account.d.ts +0 -21
  220. package/dist/hooks/settings/use-unlink-account.js +0 -17
  221. package/dist/hooks/settings/use-update-user.d.ts +0 -1185
  222. package/dist/hooks/settings/use-update-user.js +0 -24
  223. package/dist/lib/auth-client.js +0 -11
  224. package/dist/lib/auth-config.d.ts +0 -43
  225. package/dist/lib/auth-context.d.ts +0 -2
  226. package/dist/lib/auth-context.js +0 -6
  227. package/dist/mutations/auth/is-username-available-options.d.ts +0 -19
  228. package/dist/mutations/auth/is-username-available-options.js +0 -7
  229. package/dist/mutations/auth/request-password-reset-options.d.ts +0 -15
  230. package/dist/mutations/auth/request-password-reset-options.js +0 -7
  231. package/dist/mutations/auth/reset-password-options.d.ts +0 -17
  232. package/dist/mutations/auth/reset-password-options.js +0 -7
  233. package/dist/mutations/auth/send-verification-email-options.d.ts +0 -15
  234. package/dist/mutations/auth/send-verification-email-options.js +0 -7
  235. package/dist/mutations/auth/sign-in-email-options.d.ts +0 -23
  236. package/dist/mutations/auth/sign-in-email-options.js +0 -11
  237. package/dist/mutations/auth/sign-in-magic-link-options.d.ts +0 -23
  238. package/dist/mutations/auth/sign-in-magic-link-options.js +0 -11
  239. package/dist/mutations/auth/sign-in-passkey-options.d.ts +0 -15
  240. package/dist/mutations/auth/sign-in-passkey-options.js +0 -11
  241. package/dist/mutations/auth/sign-in-social-options.d.ts +0 -61
  242. package/dist/mutations/auth/sign-in-social-options.js +0 -11
  243. package/dist/mutations/auth/sign-in-username-options.d.ts +0 -19
  244. package/dist/mutations/auth/sign-in-username-options.js +0 -11
  245. package/dist/mutations/auth/sign-out-options.d.ts +0 -12
  246. package/dist/mutations/auth/sign-out-options.js +0 -7
  247. package/dist/mutations/auth/sign-up-email-options.d.ts +0 -1180
  248. package/dist/mutations/auth/sign-up-email-options.js +0 -11
  249. package/dist/mutations/settings/add-passkey-options.d.ts +0 -15
  250. package/dist/mutations/settings/add-passkey-options.js +0 -11
  251. package/dist/mutations/settings/change-email-options.d.ts +0 -15
  252. package/dist/mutations/settings/change-email-options.js +0 -7
  253. package/dist/mutations/settings/change-password-options.d.ts +0 -17
  254. package/dist/mutations/settings/change-password-options.js +0 -7
  255. package/dist/mutations/settings/delete-passkey-options.d.ts +0 -13
  256. package/dist/mutations/settings/delete-passkey-options.js +0 -11
  257. package/dist/mutations/settings/delete-user-options.d.ts +0 -20
  258. package/dist/mutations/settings/delete-user-options.js +0 -7
  259. package/dist/mutations/settings/link-social-options.d.ts +0 -39
  260. package/dist/mutations/settings/link-social-options.js +0 -7
  261. package/dist/mutations/settings/revoke-multi-session-options.d.ts +0 -13
  262. package/dist/mutations/settings/revoke-multi-session-options.js +0 -11
  263. package/dist/mutations/settings/revoke-session-options.d.ts +0 -13
  264. package/dist/mutations/settings/revoke-session-options.js +0 -7
  265. package/dist/mutations/settings/set-active-session-options.d.ts +0 -13
  266. package/dist/mutations/settings/set-active-session-options.js +0 -11
  267. package/dist/mutations/settings/unlink-account-options.d.ts +0 -15
  268. package/dist/mutations/settings/unlink-account-options.js +0 -7
  269. package/dist/mutations/settings/update-user-options.d.ts +0 -1182
  270. package/dist/mutations/settings/update-user-options.js +0 -7
  271. package/dist/queries/auth/session-options.d.ts +0 -110
  272. package/dist/queries/auth/session-options.js +0 -7
  273. package/dist/queries/settings/account-info-options.d.ts +0 -32
  274. package/dist/queries/settings/account-info-options.js +0 -12
  275. package/dist/queries/settings/list-accounts-options.d.ts +0 -53
  276. package/dist/queries/settings/list-accounts-options.js +0 -12
  277. package/dist/queries/settings/list-device-sessions-options.d.ts +0 -99
  278. package/dist/queries/settings/list-device-sessions-options.js +0 -12
  279. package/dist/queries/settings/list-sessions-options.d.ts +0 -54
  280. package/dist/queries/settings/list-sessions-options.js +0 -12
  281. package/dist/queries/settings/list-user-passkeys-options.d.ts +0 -18
  282. package/dist/queries/settings/list-user-passkeys-options.js +0 -12
  283. package/src/core.ts +0 -1
  284. package/src/hooks/auth/use-is-username-available.ts +0 -31
  285. package/src/hooks/auth/use-request-password-reset.ts +0 -33
  286. package/src/hooks/auth/use-reset-password.ts +0 -31
  287. package/src/hooks/auth/use-send-verification-email.ts +0 -31
  288. package/src/hooks/auth/use-session.ts +0 -31
  289. package/src/hooks/auth/use-sign-in-email.ts +0 -41
  290. package/src/hooks/auth/use-sign-in-magic-link.ts +0 -29
  291. package/src/hooks/auth/use-sign-in-passkey.ts +0 -40
  292. package/src/hooks/auth/use-sign-in-social.ts +0 -31
  293. package/src/hooks/auth/use-sign-in-username.ts +0 -40
  294. package/src/hooks/auth/use-sign-out.ts +0 -34
  295. package/src/hooks/auth/use-sign-up-email.ts +0 -40
  296. package/src/hooks/settings/use-account-info.ts +0 -40
  297. package/src/hooks/settings/use-add-passkey.ts +0 -37
  298. package/src/hooks/settings/use-change-email.ts +0 -37
  299. package/src/hooks/settings/use-change-password.ts +0 -29
  300. package/src/hooks/settings/use-delete-passkey.ts +0 -37
  301. package/src/hooks/settings/use-delete-user.ts +0 -29
  302. package/src/hooks/settings/use-link-social.ts +0 -29
  303. package/src/hooks/settings/use-list-accounts.ts +0 -39
  304. package/src/hooks/settings/use-list-device-sessions.ts +0 -39
  305. package/src/hooks/settings/use-list-sessions.ts +0 -39
  306. package/src/hooks/settings/use-list-user-passkeys.ts +0 -39
  307. package/src/hooks/settings/use-revoke-multi-session.ts +0 -39
  308. package/src/hooks/settings/use-revoke-session.ts +0 -39
  309. package/src/hooks/settings/use-set-active-session.ts +0 -58
  310. package/src/hooks/settings/use-unlink-account.ts +0 -37
  311. package/src/hooks/settings/use-update-user.ts +0 -50
  312. package/src/lib/auth-config.ts +0 -48
  313. package/src/lib/auth-context.ts +0 -6
  314. package/src/mutations/auth/is-username-available-options.ts +0 -18
  315. package/src/mutations/auth/request-password-reset-options.ts +0 -14
  316. package/src/mutations/auth/reset-password-options.ts +0 -14
  317. package/src/mutations/auth/send-verification-email-options.ts +0 -14
  318. package/src/mutations/auth/sign-in-email-options.ts +0 -19
  319. package/src/mutations/auth/sign-in-magic-link-options.ts +0 -15
  320. package/src/mutations/auth/sign-in-passkey-options.ts +0 -15
  321. package/src/mutations/auth/sign-in-social-options.ts +0 -19
  322. package/src/mutations/auth/sign-in-username-options.ts +0 -15
  323. package/src/mutations/auth/sign-out-options.ts +0 -11
  324. package/src/mutations/auth/sign-up-email-options.ts +0 -15
  325. package/src/mutations/settings/add-passkey-options.ts +0 -15
  326. package/src/mutations/settings/change-email-options.ts +0 -11
  327. package/src/mutations/settings/change-password-options.ts +0 -14
  328. package/src/mutations/settings/delete-passkey-options.ts +0 -15
  329. package/src/mutations/settings/delete-user-options.ts +0 -11
  330. package/src/mutations/settings/link-social-options.ts +0 -11
  331. package/src/mutations/settings/revoke-multi-session-options.ts +0 -15
  332. package/src/mutations/settings/revoke-session-options.ts +0 -14
  333. package/src/mutations/settings/set-active-session-options.ts +0 -15
  334. package/src/mutations/settings/unlink-account-options.ts +0 -14
  335. package/src/mutations/settings/update-user-options.ts +0 -15
  336. package/src/queries/auth/session-options.ts +0 -18
  337. package/src/queries/settings/account-info-options.ts +0 -25
  338. package/src/queries/settings/list-accounts-options.ts +0 -26
  339. package/src/queries/settings/list-device-sessions-options.ts +0 -24
  340. package/src/queries/settings/list-sessions-options.ts +0 -23
  341. package/src/queries/settings/list-user-passkeys-options.ts +0 -23
  342. /package/dist/components/{email → auth/email}/email-changed.d.ts +0 -0
  343. /package/dist/components/{email → auth/email}/email-localization.d.ts +0 -0
  344. /package/dist/components/{email → auth/email}/email-styles.d.ts +0 -0
  345. /package/dist/components/{email → auth/email}/email-verification.d.ts +0 -0
  346. /package/dist/components/{email → auth/email}/index.d.ts +0 -0
  347. /package/dist/components/{email → auth/email}/index.js +0 -0
  348. /package/dist/components/{email → auth/email}/magic-link.d.ts +0 -0
  349. /package/dist/components/{email → auth/email}/new-device.d.ts +0 -0
  350. /package/dist/components/{email → auth/email}/otp-email.d.ts +0 -0
  351. /package/dist/components/{email → auth/email}/password-changed.d.ts +0 -0
  352. /package/dist/components/{email → auth/email}/reset-password.d.ts +0 -0
  353. /package/src/components/{email → auth/email}/email-localization.tsx +0 -0
  354. /package/src/components/{email → auth/email}/email-styles.tsx +0 -0
  355. /package/src/components/{email → auth/email}/index.ts +0 -0
@@ -0,0 +1,71 @@
1
+ import { DataTag, QueryClient } from '@tanstack/react-query';
2
+ import { BetterFetchError } from 'better-auth/react';
3
+ import { AuthClient, InferData } from '../../lib/auth-client';
4
+ export type SessionData<TAuthClient extends AuthClient = AuthClient> = InferData<TAuthClient["getSession"]>;
5
+ export type Session<TAuthClient extends AuthClient = AuthClient> = NonNullable<SessionData<TAuthClient>>;
6
+ export type SessionParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["getSession"]>[0];
7
+ export type SessionOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof sessionOptions<TAuthClient>>, "queryKey" | "queryFn">;
8
+ /**
9
+ * Query options factory for the current session.
10
+ *
11
+ * Shares a query key with the server-side `sessionOptions` so that data
12
+ * prefetched during SSR hydrates seamlessly into the client cache.
13
+ *
14
+ * @param authClient - The Better Auth client.
15
+ * @param params - Parameters forwarded to `authClient.getSession`.
16
+ */
17
+ export declare function sessionOptions<TAuthClient extends AuthClient>(authClient: TAuthClient, params?: SessionParams<TAuthClient>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<InferData<TAuthClient["getSession"]>, BetterFetchError, InferData<TAuthClient["getSession"]>, readonly ["auth", "getSession"]>, "queryFn"> & {
18
+ queryFn?: import('@tanstack/react-query').QueryFunction<InferData<TAuthClient["getSession"]>, readonly ["auth", "getSession"], never> | undefined;
19
+ } & {
20
+ queryKey: readonly ["auth", "getSession"] & {
21
+ [dataTagSymbol]: InferData<TAuthClient["getSession"]>;
22
+ [dataTagErrorSymbol]: BetterFetchError;
23
+ };
24
+ }) & {
25
+ queryKey: DataTag<readonly ["auth", "getSession"], InferData<TAuthClient["getSession"]>, BetterFetchError>;
26
+ };
27
+ /**
28
+ * Get the current session from the query cache, calling `fetchSession` under
29
+ * the hood if no cached entry exists. Resolves with the session data, making
30
+ * it ideal for loaders or `beforeLoad` guards.
31
+ *
32
+ * @param queryClient - The React Query client.
33
+ * @param authClient - The Better Auth client.
34
+ * @param params - Parameters forwarded to `authClient.getSession`.
35
+ */
36
+ export declare const ensureSession: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, params?: SessionParams<TAuthClient>) => Promise<InferData<TAuthClient["getSession"]>>;
37
+ /**
38
+ * Prefetch the current session into the query cache. Behaves like
39
+ * `fetchSession`, but does not throw on error and does not return the data —
40
+ * use this to warm the cache without blocking navigation.
41
+ *
42
+ * @param queryClient - The React Query client.
43
+ * @param authClient - The Better Auth client.
44
+ * @param params - Parameters forwarded to `authClient.getSession`.
45
+ */
46
+ export declare const prefetchSession: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, params?: SessionParams<TAuthClient>) => Promise<void>;
47
+ /**
48
+ * Fetch and cache the current session, resolving with the data or throwing
49
+ * on error. If a cached entry exists and is neither invalidated nor older
50
+ * than `staleTime`, the cached value is returned without a network call;
51
+ * otherwise the latest data is fetched.
52
+ *
53
+ * @param queryClient - The React Query client.
54
+ * @param authClient - The Better Auth client.
55
+ * @param params - Parameters forwarded to `authClient.getSession`.
56
+ */
57
+ export declare const fetchSession: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, params?: SessionParams<TAuthClient>) => Promise<InferData<TAuthClient["getSession"]>>;
58
+ export type UseSessionOptions<TAuthClient extends AuthClient> = SessionOptions<TAuthClient> & SessionParams<TAuthClient>;
59
+ /**
60
+ * Subscribe to the current session via TanStack Query.
61
+ *
62
+ * Shares a query key with the server-side `sessionOptions`, so SSR-hydrated
63
+ * session data is reused from the cache without an immediate refetch.
64
+ *
65
+ * @param authClient - The Better Auth client.
66
+ * @param options - `getSession` params (`query`, `fetchOptions`) merged
67
+ * with `useQuery` options (e.g. `enabled`, `staleTime`, `select`).
68
+ * @param queryClient - Optional custom `QueryClient`. Defaults to the client
69
+ * from the nearest `QueryClientProvider`.
70
+ */
71
+ export declare function useSession<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: UseSessionOptions<TAuthClient>, queryClient?: QueryClient): import('@tanstack/react-query').UseQueryResult<import('@tanstack/react-query').NoInfer<InferData<TAuthClient["getSession"]>>, BetterFetchError>;
@@ -0,0 +1,30 @@
1
+ import { authQueryKeys as e } from "@better-auth-ui/core";
2
+ import { queryOptions as t, useQuery as n } from "@tanstack/react-query";
3
+ //#region src/queries/auth/session-query.ts
4
+ function r(n, r) {
5
+ let i = e.session;
6
+ return t({
7
+ queryKey: i,
8
+ queryFn: ({ signal: e }) => n.getSession({
9
+ ...r,
10
+ fetchOptions: {
11
+ ...r?.fetchOptions,
12
+ signal: e,
13
+ throw: !0
14
+ }
15
+ })
16
+ });
17
+ }
18
+ var i = (e, t, n) => e.ensureQueryData(r(t, n)), a = (e, t, n) => e.prefetchQuery(r(t, n)), o = (e, t, n) => e.fetchQuery(r(t, n));
19
+ function s(e, t = {}, i) {
20
+ let { query: a, fetchOptions: o, ...s } = t;
21
+ return n({
22
+ ...r(e, {
23
+ query: a,
24
+ fetchOptions: o
25
+ }),
26
+ ...s
27
+ }, i);
28
+ }
29
+ //#endregion
30
+ export { i as ensureSession, o as fetchSession, a as prefetchSession, r as sessionOptions, s as useSession };
@@ -1,29 +1,40 @@
1
- import { QueryKey } from '@tanstack/react-query';
1
+ import { DataTag, QueryKey, UseQueryOptions } from '@tanstack/react-query';
2
2
  import { BetterFetchError, BetterFetchOption } from 'better-auth/client';
3
- export type AuthFn<TData = unknown> = (params: {
3
+ /**
4
+ * Read-style Better Auth client method (params shape `{ query?, fetchOptions? }`).
5
+ * Mutation-style endpoints use `AuthMutationFn` / `useAuthMutation` instead.
6
+ */
7
+ export type AuthQueryFn<TData = unknown> = (params: {
4
8
  query?: Record<string, unknown>;
5
9
  fetchOptions?: BetterFetchOption;
6
10
  }) => Promise<{
7
11
  data: TData;
8
12
  }>;
9
- type AuthFnData<TFn> = TFn extends AuthFn<infer TData> ? TData : never;
13
+ export type AuthQueryFnData<TFn> = TFn extends AuthQueryFn<infer TData> ? TData : never;
14
+ /**
15
+ * Final query key produced by {@link authQueryOptions}: the caller's prefix
16
+ * followed by `params.query ?? null`.
17
+ */
18
+ export type AuthQueryKey<TFn extends AuthQueryFn = AuthQueryFn, TPrefix extends QueryKey = QueryKey> = readonly [...TPrefix, NonNullable<Parameters<TFn>[0]>["query"] | null];
19
+ /**
20
+ * Return type of {@link authQueryOptions}. Named so TypeScript emits
21
+ * `DataTag<…>` by reference in the `.d.ts`, instead of the raw
22
+ * `{ [dataTagSymbol]: … }` intersection — which triggers a declaration-emit
23
+ * bug where `dataTagSymbol` isn't re-imported at the use site and silently
24
+ * breaks `setQueryData`/`getQueryData` type inference at the consumer.
25
+ */
26
+ export type AuthQueryOptions<TFn extends AuthQueryFn = AuthQueryFn, TPrefix extends QueryKey = QueryKey> = Omit<UseQueryOptions<AuthQueryFnData<TFn>, BetterFetchError, AuthQueryFnData<TFn>, AuthQueryKey<TFn, TPrefix>>, "queryKey"> & {
27
+ queryKey: DataTag<AuthQueryKey<TFn, TPrefix>, AuthQueryFnData<TFn>, BetterFetchError>;
28
+ };
10
29
  /**
11
30
  * Build `queryOptions` for a Better Auth endpoint.
12
31
  *
13
- * Appends `params.query` (or `null`) to the supplied `queryKey` so cache
14
- * identity tracks endpoint inputs. Wires `throw: true` and the React Query
15
- * `AbortSignal` into `fetchOptions`.
32
+ * Injects React Query's `signal` and `throw: true` into `fetchOptions` so the
33
+ * request is cancelled on unmount and errors surface as `BetterFetchError`
34
+ * instead of `{ data, error }`.
16
35
  *
17
36
  * @param authFn - Better Auth client method (e.g. `authClient.getSession`).
18
37
  * @param queryKey - Scope prefix for the key. `params.query` is appended automatically.
19
38
  * @param params - Parameters forwarded to `authFn`.
20
39
  */
21
- export declare function authQueryOptions<TFn extends AuthFn, const TQueryKey extends QueryKey>(authFn: TFn, queryKey: TQueryKey, params?: Parameters<TFn>[0]): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<AuthFnData<TFn>, BetterFetchError, AuthFnData<TFn>, readonly unknown[]>, "queryFn"> & {
22
- queryFn?: import('@tanstack/react-query').QueryFunction<AuthFnData<TFn>, readonly unknown[], never> | undefined;
23
- } & {
24
- queryKey: readonly unknown[] & {
25
- [dataTagSymbol]: AuthFnData<TFn>;
26
- [dataTagErrorSymbol]: BetterFetchError;
27
- };
28
- };
29
- export {};
40
+ export declare function authQueryOptions<TFn extends AuthQueryFn, const TPrefix extends QueryKey>(authFn: TFn, queryKey: TPrefix, params?: Parameters<TFn>[0]): AuthQueryOptions<TFn, TPrefix>;
@@ -0,0 +1,76 @@
1
+ import { DataTag, QueryClient } from '@tanstack/react-query';
2
+ import { BetterFetchError } from 'better-auth/react';
3
+ import { InferData, MultiSessionAuthClient } from '../../lib/auth-client';
4
+ export type ListDeviceSessionsData<TAuthClient extends MultiSessionAuthClient = MultiSessionAuthClient> = InferData<TAuthClient["multiSession"]["listDeviceSessions"]>;
5
+ export type ListDeviceSession<TAuthClient extends MultiSessionAuthClient = MultiSessionAuthClient> = NonNullable<ListDeviceSessionsData<TAuthClient>>[number];
6
+ export type ListDeviceSessionsParams<TAuthClient extends MultiSessionAuthClient> = Parameters<TAuthClient["multiSession"]["listDeviceSessions"]>[0];
7
+ export type ListDeviceSessionsOptions<TAuthClient extends MultiSessionAuthClient> = Omit<ReturnType<typeof listDeviceSessionsOptions<TAuthClient>>, "queryKey" | "queryFn">;
8
+ /**
9
+ * Query options factory for the current user's device sessions.
10
+ *
11
+ * @param authClient - The Better Auth client with the multi-session plugin.
12
+ * @param userId - The current signed-in user's ID. Used for cache partitioning.
13
+ * @param params - Parameters forwarded to `authClient.multiSession.listDeviceSessions`.
14
+ */
15
+ export declare function listDeviceSessionsOptions<TAuthClient extends MultiSessionAuthClient>(authClient: TAuthClient, userId: string | undefined, params?: ListDeviceSessionsParams<TAuthClient>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<InferData<TAuthClient["multiSession"]["listDeviceSessions"]>, BetterFetchError, InferData<TAuthClient["multiSession"]["listDeviceSessions"]>, readonly ["auth", "user", string | undefined, "listDeviceSessions", Record<string, any> | null]>, "queryFn"> & {
16
+ queryFn?: import('@tanstack/react-query').QueryFunction<InferData<TAuthClient["multiSession"]["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]: InferData<TAuthClient["multiSession"]["listDeviceSessions"]>;
20
+ [dataTagErrorSymbol]: BetterFetchError;
21
+ };
22
+ }) & {
23
+ queryKey: DataTag<readonly ["auth", "user", string | undefined, "listDeviceSessions", Record<string, any> | null], InferData<TAuthClient["multiSession"]["listDeviceSessions"]>, BetterFetchError>;
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 ideal for loaders or
29
+ * `beforeLoad` guards.
30
+ *
31
+ * @param queryClient - The React Query client.
32
+ * @param authClient - The Better Auth client with the multi-session plugin.
33
+ * @param userId - The signed-in user's ID, used for cache partitioning.
34
+ * @param params - Parameters forwarded to `authClient.multiSession.listDeviceSessions`.
35
+ */
36
+ export declare const ensureListDeviceSessions: <TAuthClient extends MultiSessionAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListDeviceSessionsParams<TAuthClient>) => Promise<InferData<TAuthClient["multiSession"]["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 to warm the cache without blocking navigation.
41
+ *
42
+ * @param queryClient - The React Query client.
43
+ * @param authClient - The Better Auth client with the multi-session plugin.
44
+ * @param userId - The signed-in user's ID, used for cache partitioning.
45
+ * @param params - Parameters forwarded to `authClient.multiSession.listDeviceSessions`.
46
+ */
47
+ export declare const prefetchListDeviceSessions: <TAuthClient extends MultiSessionAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListDeviceSessionsParams<TAuthClient>) => Promise<void>;
48
+ /**
49
+ * Fetch and cache the current user's device sessions, resolving with the
50
+ * data or throwing on error. If a cached entry exists and is neither
51
+ * invalidated nor older than `staleTime`, the cached value is returned
52
+ * without a network call; otherwise the latest data is fetched.
53
+ *
54
+ * @param queryClient - The React Query client.
55
+ * @param authClient - The Better Auth client with the multi-session plugin.
56
+ * @param userId - The signed-in user's ID, used for cache partitioning.
57
+ * @param params - Parameters forwarded to `authClient.multiSession.listDeviceSessions`.
58
+ */
59
+ export declare const fetchListDeviceSessions: <TAuthClient extends MultiSessionAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListDeviceSessionsParams<TAuthClient>) => Promise<InferData<TAuthClient["multiSession"]["listDeviceSessions"]>>;
60
+ export type UseListDeviceSessionsOptions<TAuthClient extends MultiSessionAuthClient> = ListDeviceSessionsOptions<TAuthClient> & ListDeviceSessionsParams<TAuthClient>;
61
+ /**
62
+ * Subscribe to the current user's device sessions (multi-session account
63
+ * switcher) via TanStack Query.
64
+ *
65
+ * Shares a query key with the server-side `listDeviceSessionsOptions`, so
66
+ * SSR-hydrated data is reused from the cache without an immediate refetch.
67
+ * The query is gated on a signed-in user; while the session is loading or
68
+ * absent, the underlying `queryFn` is replaced with `skipToken`.
69
+ *
70
+ * @param authClient - The Better Auth client with the multi-session plugin.
71
+ * @param options - `listDeviceSessions` params (`query`, `fetchOptions`)
72
+ * merged with `useQuery` options (e.g. `enabled`, `staleTime`, `select`).
73
+ * @param queryClient - Optional custom `QueryClient`. Defaults to the client
74
+ * from the nearest `QueryClientProvider`.
75
+ */
76
+ export declare function useListDeviceSessions<TAuthClient extends MultiSessionAuthClient>(authClient: TAuthClient, options?: UseListDeviceSessionsOptions<TAuthClient>, queryClient?: QueryClient): import('@tanstack/react-query').UseQueryResult<import('@tanstack/react-query').NoInfer<InferData<TAuthClient["multiSession"]["listDeviceSessions"]>>, BetterFetchError>;
@@ -0,0 +1,31 @@
1
+ import { useSession as e } from "../auth/session-query.js";
2
+ import { authQueryKeys as t } from "@better-auth-ui/core";
3
+ import { queryOptions as n, skipToken as r, useQuery as i } from "@tanstack/react-query";
4
+ //#region src/queries/multi-session/list-device-sessions-query.ts
5
+ function a(e, r, i) {
6
+ return n({
7
+ queryKey: t.listDeviceSessions(r, i?.query),
8
+ queryFn: ({ signal: t }) => e.multiSession.listDeviceSessions({
9
+ ...i,
10
+ fetchOptions: {
11
+ ...i?.fetchOptions,
12
+ signal: t,
13
+ throw: !0
14
+ }
15
+ })
16
+ });
17
+ }
18
+ var o = (e, t, n, r) => e.ensureQueryData(a(t, n, r)), s = (e, t, n, r) => e.prefetchQuery(a(t, n, r)), c = (e, t, n, r) => e.fetchQuery(a(t, n, r));
19
+ function l(t, n = {}, o) {
20
+ let { data: s } = e(t, void 0, o), c = s?.user.id, { query: l, fetchOptions: u, ...d } = n, f = a(t, c, {
21
+ query: l,
22
+ fetchOptions: u
23
+ });
24
+ return i({
25
+ ...d,
26
+ ...f,
27
+ queryFn: c ? f.queryFn : r
28
+ }, o);
29
+ }
30
+ //#endregion
31
+ export { o as ensureListDeviceSessions, c as fetchListDeviceSessions, a as listDeviceSessionsOptions, s as prefetchListDeviceSessions, l as useListDeviceSessions };
@@ -0,0 +1,74 @@
1
+ import { DataTag, QueryClient } from '@tanstack/react-query';
2
+ import { BetterFetchError } from 'better-auth/react';
3
+ import { InferData, PasskeyAuthClient } from '../../lib/auth-client';
4
+ export type ListPasskeysData<TAuthClient extends PasskeyAuthClient> = InferData<TAuthClient["passkey"]["listUserPasskeys"]>;
5
+ export type ListPasskeysParams<TAuthClient extends PasskeyAuthClient> = Parameters<TAuthClient["passkey"]["listUserPasskeys"]>[0];
6
+ export type ListPasskey<TAuthClient extends PasskeyAuthClient = PasskeyAuthClient> = NonNullable<ListPasskeysData<TAuthClient>>[number];
7
+ export type ListPasskeysOptions<TAuthClient extends PasskeyAuthClient> = Omit<ReturnType<typeof listPasskeysOptions<TAuthClient>>, "queryKey" | "queryFn">;
8
+ /**
9
+ * Query options factory for the current user's passkeys.
10
+ *
11
+ * @param authClient - The Better Auth client with the passkey plugin.
12
+ * @param userId - The current signed-in user's ID. Used for cache partitioning.
13
+ * @param params - Parameters forwarded to `authClient.passkey.listUserPasskeys`.
14
+ */
15
+ export declare function listPasskeysOptions<TAuthClient extends PasskeyAuthClient>(authClient: TAuthClient, userId: string | undefined, params?: ListPasskeysParams<TAuthClient>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<InferData<TAuthClient["passkey"]["listUserPasskeys"]>, BetterFetchError, InferData<TAuthClient["passkey"]["listUserPasskeys"]>, readonly ["auth", "user", string | undefined, "listPasskeys", Record<string, any> | null]>, "queryFn"> & {
16
+ queryFn?: import('@tanstack/react-query').QueryFunction<InferData<TAuthClient["passkey"]["listUserPasskeys"]>, 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]: InferData<TAuthClient["passkey"]["listUserPasskeys"]>;
20
+ [dataTagErrorSymbol]: BetterFetchError;
21
+ };
22
+ }) & {
23
+ queryKey: DataTag<readonly ["auth", "user", string | undefined, "listPasskeys", Record<string, any> | null], InferData<TAuthClient["passkey"]["listUserPasskeys"]>, BetterFetchError>;
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 ideal for loaders or `beforeLoad` guards.
29
+ *
30
+ * @param queryClient - The React Query client.
31
+ * @param authClient - The Better Auth client with the passkey plugin.
32
+ * @param userId - The signed-in user's ID, used for cache partitioning.
33
+ * @param params - Parameters forwarded to `authClient.passkey.listUserPasskeys`.
34
+ */
35
+ export declare const ensureListPasskeys: <TAuthClient extends PasskeyAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListPasskeysParams<TAuthClient>) => Promise<InferData<TAuthClient["passkey"]["listUserPasskeys"]>>;
36
+ /**
37
+ * Prefetch the current user's passkeys into the query cache. Behaves like
38
+ * `fetchListPasskeys`, but does not throw on error and does not return
39
+ * the data — use this to warm the cache without blocking navigation.
40
+ *
41
+ * @param queryClient - The React Query client.
42
+ * @param authClient - The Better Auth client with the passkey plugin.
43
+ * @param userId - The signed-in user's ID, used for cache partitioning.
44
+ * @param params - Parameters forwarded to `authClient.passkey.listUserPasskeys`.
45
+ */
46
+ export declare const prefetchListPasskeys: <TAuthClient extends PasskeyAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListPasskeysParams<TAuthClient>) => Promise<void>;
47
+ /**
48
+ * Fetch and cache the current user's passkeys, resolving with the data or
49
+ * throwing on error. If a cached entry exists and is neither invalidated
50
+ * nor older than `staleTime`, the cached value is returned without a
51
+ * network call; otherwise the latest data is fetched.
52
+ *
53
+ * @param queryClient - The React Query client.
54
+ * @param authClient - The Better Auth client with the passkey plugin.
55
+ * @param userId - The signed-in user's ID, used for cache partitioning.
56
+ * @param params - Parameters forwarded to `authClient.passkey.listUserPasskeys`.
57
+ */
58
+ export declare const fetchListPasskeys: <TAuthClient extends PasskeyAuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListPasskeysParams<TAuthClient>) => Promise<InferData<TAuthClient["passkey"]["listUserPasskeys"]>>;
59
+ export type UseListPasskeysOptions<TAuthClient extends PasskeyAuthClient> = ListPasskeysOptions<TAuthClient> & ListPasskeysParams<TAuthClient>;
60
+ /**
61
+ * Subscribe to the current user's passkeys via TanStack Query.
62
+ *
63
+ * Shares a query key with the server-side `listPasskeysOptions`, so
64
+ * SSR-hydrated data is reused from the cache without an immediate refetch.
65
+ * The query is gated on a signed-in user; while the session is loading or
66
+ * absent, the underlying `queryFn` is replaced with `skipToken`.
67
+ *
68
+ * @param authClient - The Better Auth client with the passkey plugin.
69
+ * @param options - `listPasskeys` params (`query`, `fetchOptions`) merged
70
+ * with `useQuery` options (e.g. `enabled`, `staleTime`, `select`).
71
+ * @param queryClient - Optional custom `QueryClient`. Defaults to the client
72
+ * from the nearest `QueryClientProvider`.
73
+ */
74
+ export declare function useListPasskeys<TAuthClient extends PasskeyAuthClient>(authClient: TAuthClient, options?: UseListPasskeysOptions<TAuthClient>, queryClient?: QueryClient): import('@tanstack/react-query').UseQueryResult<import('@tanstack/react-query').NoInfer<InferData<TAuthClient["passkey"]["listUserPasskeys"]>>, BetterFetchError>;
@@ -0,0 +1,31 @@
1
+ import { useSession as e } from "../auth/session-query.js";
2
+ import { authQueryKeys as t } from "@better-auth-ui/core";
3
+ import { queryOptions as n, skipToken as r, useQuery as i } from "@tanstack/react-query";
4
+ //#region src/queries/passkey/list-passkeys-query.ts
5
+ function a(e, r, i) {
6
+ return n({
7
+ queryKey: t.listPasskeys(r, i?.query),
8
+ queryFn: ({ signal: t }) => e.passkey.listUserPasskeys({
9
+ ...i,
10
+ fetchOptions: {
11
+ ...i?.fetchOptions,
12
+ signal: t,
13
+ throw: !0
14
+ }
15
+ })
16
+ });
17
+ }
18
+ var o = (e, t, n, r) => e.ensureQueryData(a(t, n, r)), s = (e, t, n, r) => e.prefetchQuery(a(t, n, r)), c = (e, t, n, r) => e.fetchQuery(a(t, n, r));
19
+ function l(t, n = {}, o) {
20
+ let { data: s } = e(t, void 0, o), c = s?.user.id, { query: l, fetchOptions: u, ...d } = n, f = a(t, c, {
21
+ query: l,
22
+ fetchOptions: u
23
+ });
24
+ return i({
25
+ ...d,
26
+ ...f,
27
+ queryFn: c ? f.queryFn : r
28
+ }, o);
29
+ }
30
+ //#endregion
31
+ export { o as ensureListPasskeys, c as fetchListPasskeys, a as listPasskeysOptions, s as prefetchListPasskeys, l as useListPasskeys };
@@ -0,0 +1,85 @@
1
+ import { DataTag, QueryClient } from '@tanstack/react-query';
2
+ import { BetterFetchError } from 'better-auth/react';
3
+ import { AuthClient, InferData } from '../../lib/auth-client';
4
+ export type AccountInfoData<TAuthClient extends AuthClient> = InferData<TAuthClient["accountInfo"]>;
5
+ export type AccountInfoParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["accountInfo"]>[0];
6
+ export type AccountInfo<TAuthClient extends AuthClient = AuthClient> = NonNullable<AccountInfoData<TAuthClient>>;
7
+ export type AccountInfoOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof accountInfoOptions<TAuthClient>>, "queryKey" | "queryFn">;
8
+ /**
9
+ * Query options factory for provider-specific account info.
10
+ *
11
+ * @param authClient - The Better Auth client.
12
+ * @param userId - The current signed-in user's ID. Used for cache partitioning.
13
+ * @param params - Parameters forwarded to `authClient.accountInfo`.
14
+ */
15
+ export declare function accountInfoOptions<TAuthClient extends AuthClient>(authClient: TAuthClient, userId: string | undefined, params?: AccountInfoParams<TAuthClient>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<InferData<TAuthClient["accountInfo"]>, BetterFetchError, InferData<TAuthClient["accountInfo"]>, readonly ["auth", "user", string | undefined, "accountInfo", {
16
+ accountId?: string | undefined;
17
+ } | null]>, "queryFn"> & {
18
+ queryFn?: import('@tanstack/react-query').QueryFunction<InferData<TAuthClient["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]: InferData<TAuthClient["accountInfo"]>;
26
+ [dataTagErrorSymbol]: BetterFetchError;
27
+ };
28
+ }) & {
29
+ queryKey: DataTag<readonly ["auth", "user", string | undefined, "accountInfo", {
30
+ accountId?: string | undefined;
31
+ } | null], InferData<TAuthClient["accountInfo"]>, BetterFetchError>;
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 ideal for loaders or
37
+ * `beforeLoad` guards.
38
+ *
39
+ * @param queryClient - The React Query client.
40
+ * @param authClient - The Better Auth client.
41
+ * @param userId - The signed-in user's ID, used for cache partitioning.
42
+ * @param params - Parameters forwarded to `authClient.accountInfo`.
43
+ */
44
+ export declare const ensureAccountInfo: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: AccountInfoParams<TAuthClient>) => Promise<InferData<TAuthClient["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 to warm the cache without blocking
49
+ * navigation.
50
+ *
51
+ * @param queryClient - The React Query client.
52
+ * @param authClient - The Better Auth client.
53
+ * @param userId - The signed-in user's ID, used for cache partitioning.
54
+ * @param params - Parameters forwarded to `authClient.accountInfo`.
55
+ */
56
+ export declare const prefetchAccountInfo: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: AccountInfoParams<TAuthClient>) => 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.
64
+ * @param authClient - The Better Auth client.
65
+ * @param userId - The signed-in user's ID, used for cache partitioning.
66
+ * @param params - Parameters forwarded to `authClient.accountInfo`.
67
+ */
68
+ export declare const fetchAccountInfo: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: AccountInfoParams<TAuthClient>) => Promise<InferData<TAuthClient["accountInfo"]>>;
69
+ export type UseAccountInfoOptions<TAuthClient extends AuthClient> = AccountInfoOptions<TAuthClient> & AccountInfoParams<TAuthClient>;
70
+ /**
71
+ * Subscribe to provider-specific info for a linked account via TanStack Query.
72
+ *
73
+ * Shares a query key with the server-side `accountInfoOptions`, so
74
+ * SSR-hydrated data is reused from the cache without an immediate refetch.
75
+ * The query is gated on both a signed-in user and a resolved `accountId`;
76
+ * until both are present, the underlying `queryFn` is replaced with
77
+ * `skipToken`.
78
+ *
79
+ * @param authClient - The Better Auth client.
80
+ * @param options - `accountInfo` params (`query`, `fetchOptions`) merged
81
+ * with `useQuery` options (e.g. `enabled`, `staleTime`, `select`).
82
+ * @param queryClient - Optional custom `QueryClient`. Defaults to the client
83
+ * from the nearest `QueryClientProvider`.
84
+ */
85
+ export declare function useAccountInfo<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: UseAccountInfoOptions<TAuthClient>, queryClient?: QueryClient): import('@tanstack/react-query').UseQueryResult<import('@tanstack/react-query').NoInfer<InferData<TAuthClient["accountInfo"]>>, BetterFetchError>;
@@ -0,0 +1,31 @@
1
+ import { useSession as e } from "../auth/session-query.js";
2
+ import { authQueryKeys as t } from "@better-auth-ui/core";
3
+ import { queryOptions as n, skipToken as r, useQuery as i } from "@tanstack/react-query";
4
+ //#region src/queries/settings/account-info-query.ts
5
+ function a(e, r, i) {
6
+ return n({
7
+ queryKey: t.accountInfo(r, i?.query),
8
+ queryFn: ({ signal: t }) => e.accountInfo({
9
+ ...i,
10
+ fetchOptions: {
11
+ ...i?.fetchOptions,
12
+ signal: t,
13
+ throw: !0
14
+ }
15
+ })
16
+ });
17
+ }
18
+ var o = (e, t, n, r) => e.ensureQueryData(a(t, n, r)), s = (e, t, n, r) => e.prefetchQuery(a(t, n, r)), c = (e, t, n, r) => e.fetchQuery(a(t, n, r));
19
+ function l(t, n = {}, o) {
20
+ let { data: s } = e(t, void 0, o), c = s?.user.id, { query: l, fetchOptions: u, ...d } = n, f = a(t, c, {
21
+ query: l,
22
+ fetchOptions: u
23
+ }), p = !!(c && l?.accountId);
24
+ return i({
25
+ ...d,
26
+ ...f,
27
+ queryFn: p ? f.queryFn : r
28
+ }, o);
29
+ }
30
+ //#endregion
31
+ export { a as accountInfoOptions, o as ensureAccountInfo, c as fetchAccountInfo, s as prefetchAccountInfo, l as useAccountInfo };
@@ -0,0 +1,76 @@
1
+ import { DataTag, QueryClient } from '@tanstack/react-query';
2
+ import { BetterFetchError } from 'better-auth/react';
3
+ import { AuthClient, InferData } from '../../lib/auth-client';
4
+ export type ListAccountsData<TAuthClient extends AuthClient> = InferData<TAuthClient["listAccounts"]>;
5
+ export type ListAccountsParams<TAuthClient extends AuthClient> = Parameters<TAuthClient["listAccounts"]>[0];
6
+ export type ListAccount<TAuthClient extends AuthClient = AuthClient> = NonNullable<ListAccountsData<TAuthClient>>[number];
7
+ export type ListAccountsOptions<TAuthClient extends AuthClient> = Omit<ReturnType<typeof listAccountsOptions<TAuthClient>>, "queryKey" | "queryFn">;
8
+ /**
9
+ * Query options factory for a user's linked social accounts.
10
+ *
11
+ * @param authClient - The Better Auth client.
12
+ * @param userId - The current signed-in user's ID. Used for cache partitioning.
13
+ * @param params - Parameters forwarded to `authClient.listAccounts`.
14
+ */
15
+ export declare function listAccountsOptions<TAuthClient extends AuthClient>(authClient: TAuthClient, userId: string | undefined, params?: ListAccountsParams<TAuthClient>): (import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<InferData<TAuthClient["listAccounts"]>, BetterFetchError, InferData<TAuthClient["listAccounts"]>, readonly ["auth", "user", string | undefined, "listAccounts", Record<string, any> | null]>, "queryFn"> & {
16
+ queryFn?: import('@tanstack/react-query').QueryFunction<InferData<TAuthClient["listAccounts"]>, 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]: InferData<TAuthClient["listAccounts"]>;
20
+ [dataTagErrorSymbol]: BetterFetchError;
21
+ };
22
+ }) & {
23
+ queryKey: DataTag<readonly ["auth", "user", string | undefined, "listAccounts", Record<string, any> | null], InferData<TAuthClient["listAccounts"]>, BetterFetchError>;
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 ideal for loaders or
29
+ * `beforeLoad` guards.
30
+ *
31
+ * @param queryClient - The React Query client.
32
+ * @param authClient - The Better Auth client.
33
+ * @param userId - The signed-in user's ID, used for cache partitioning.
34
+ * @param params - Parameters forwarded to `authClient.listAccounts`.
35
+ */
36
+ export declare const ensureListAccounts: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListAccountsParams<TAuthClient>) => Promise<InferData<TAuthClient["listAccounts"]>>;
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 to warm the cache without blocking
41
+ * navigation.
42
+ *
43
+ * @param queryClient - The React Query client.
44
+ * @param authClient - The Better Auth client.
45
+ * @param userId - The signed-in user's ID, used for cache partitioning.
46
+ * @param params - Parameters forwarded to `authClient.listAccounts`.
47
+ */
48
+ export declare const prefetchListAccounts: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListAccountsParams<TAuthClient>) => 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.
56
+ * @param authClient - The Better Auth client.
57
+ * @param userId - The signed-in user's ID, used for cache partitioning.
58
+ * @param params - Parameters forwarded to `authClient.listAccounts`.
59
+ */
60
+ export declare const fetchListAccounts: <TAuthClient extends AuthClient>(queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListAccountsParams<TAuthClient>) => Promise<InferData<TAuthClient["listAccounts"]>>;
61
+ export type UseListAccountsOptions<TAuthClient extends AuthClient> = ListAccountsOptions<TAuthClient> & ListAccountsParams<TAuthClient>;
62
+ /**
63
+ * Subscribe to the current user's linked social accounts via TanStack Query.
64
+ *
65
+ * Shares a query key with the server-side `listAccountsOptions`, so
66
+ * SSR-hydrated data is reused from the cache without an immediate refetch.
67
+ * The query is gated on a signed-in user; while the session is loading or
68
+ * absent, the underlying `queryFn` is replaced with `skipToken`.
69
+ *
70
+ * @param authClient - The Better Auth client.
71
+ * @param options - `listAccounts` params (`query`, `fetchOptions`) merged
72
+ * with `useQuery` options (e.g. `enabled`, `staleTime`, `select`).
73
+ * @param queryClient - Optional custom `QueryClient`. Defaults to the client
74
+ * from the nearest `QueryClientProvider`.
75
+ */
76
+ export declare function useListAccounts<TAuthClient extends AuthClient>(authClient: TAuthClient, options?: UseListAccountsOptions<TAuthClient>, queryClient?: QueryClient): import('@tanstack/react-query').UseQueryResult<import('@tanstack/react-query').NoInfer<InferData<TAuthClient["listAccounts"]>>, BetterFetchError>;
@@ -0,0 +1,31 @@
1
+ import { useSession as e } from "../auth/session-query.js";
2
+ import { authQueryKeys as t } from "@better-auth-ui/core";
3
+ import { queryOptions as n, skipToken as r, useQuery as i } from "@tanstack/react-query";
4
+ //#region src/queries/settings/list-accounts-query.ts
5
+ function a(e, r, i) {
6
+ return n({
7
+ queryKey: t.listAccounts(r, i?.query),
8
+ queryFn: ({ signal: t }) => e.listAccounts({
9
+ ...i,
10
+ fetchOptions: {
11
+ ...i?.fetchOptions,
12
+ signal: t,
13
+ throw: !0
14
+ }
15
+ })
16
+ });
17
+ }
18
+ var o = (e, t, n, r) => e.ensureQueryData(a(t, n, r)), s = (e, t, n, r) => e.prefetchQuery(a(t, n, r)), c = (e, t, n, r) => e.fetchQuery(a(t, n, r));
19
+ function l(t, n = {}, o) {
20
+ let { data: s } = e(t, void 0, o), c = s?.user.id, { query: l, fetchOptions: u, ...d } = n, f = a(t, c, {
21
+ query: l,
22
+ fetchOptions: u
23
+ });
24
+ return i({
25
+ ...d,
26
+ ...f,
27
+ queryFn: c ? f.queryFn : r
28
+ }, o);
29
+ }
30
+ //#endregion
31
+ export { o as ensureListAccounts, c as fetchListAccounts, a as listAccountsOptions, s as prefetchListAccounts, l as useListAccounts };