@better-auth-ui/react 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/dist/components/auth/auth-provider.d.ts +32 -0
  2. package/dist/components/auth/auth-provider.js +44 -0
  3. package/dist/components/email/email-changed.d.ts +97 -0
  4. package/dist/components/email/email-changed.js +70 -0
  5. package/dist/components/email/email-localization.d.ts +61 -0
  6. package/dist/components/email/email-localization.js +24 -0
  7. package/dist/components/email/email-styles.d.ts +89 -0
  8. package/dist/components/email/email-styles.js +129 -0
  9. package/dist/components/email/email-verification.d.ts +97 -0
  10. package/dist/components/email/email-verification.js +75 -0
  11. package/dist/components/email/index.d.ts +9 -0
  12. package/dist/components/email/index.js +9 -0
  13. package/dist/components/email/magic-link.d.ts +93 -0
  14. package/dist/components/email/magic-link.js +72 -0
  15. package/dist/components/email/new-device.d.ts +123 -0
  16. package/dist/components/email/new-device.js +90 -0
  17. package/dist/components/email/otp-email.d.ts +88 -0
  18. package/dist/components/email/otp-email.js +65 -0
  19. package/dist/components/email/password-changed.d.ts +96 -0
  20. package/dist/components/email/password-changed.js +76 -0
  21. package/dist/components/email/reset-password.d.ts +90 -0
  22. package/dist/components/email/reset-password.js +68 -0
  23. package/dist/components/icons/apple.d.ts +8 -0
  24. package/dist/components/icons/apple.js +10 -0
  25. package/dist/components/icons/atlassian.d.ts +10 -0
  26. package/dist/components/icons/atlassian.js +14 -0
  27. package/dist/components/icons/cognito.d.ts +8 -0
  28. package/dist/components/icons/cognito.js +10 -0
  29. package/dist/components/icons/discord.d.ts +8 -0
  30. package/dist/components/icons/discord.js +10 -0
  31. package/dist/components/icons/dropbox.d.ts +8 -0
  32. package/dist/components/icons/dropbox.js +10 -0
  33. package/dist/components/icons/facebook.d.ts +10 -0
  34. package/dist/components/icons/facebook.js +12 -0
  35. package/dist/components/icons/figma.d.ts +11 -0
  36. package/dist/components/icons/figma.js +13 -0
  37. package/dist/components/icons/github.d.ts +10 -0
  38. package/dist/components/icons/github.js +12 -0
  39. package/dist/components/icons/gitlab.d.ts +8 -0
  40. package/dist/components/icons/gitlab.js +10 -0
  41. package/dist/components/icons/google.d.ts +8 -0
  42. package/dist/components/icons/google.js +10 -0
  43. package/dist/components/icons/huggingface.d.ts +8 -0
  44. package/dist/components/icons/huggingface.js +10 -0
  45. package/dist/components/icons/index.d.ts +35 -0
  46. package/dist/components/icons/index.js +35 -0
  47. package/dist/components/icons/kakao.d.ts +10 -0
  48. package/dist/components/icons/kakao.js +12 -0
  49. package/dist/components/icons/kick.d.ts +10 -0
  50. package/dist/components/icons/kick.js +12 -0
  51. package/dist/components/icons/line.d.ts +8 -0
  52. package/dist/components/icons/line.js +10 -0
  53. package/dist/components/icons/linear.d.ts +8 -0
  54. package/dist/components/icons/linear.js +10 -0
  55. package/dist/components/icons/linkedin.d.ts +8 -0
  56. package/dist/components/icons/linkedin.js +10 -0
  57. package/dist/components/icons/microsoft.d.ts +8 -0
  58. package/dist/components/icons/microsoft.js +10 -0
  59. package/dist/components/icons/naver.d.ts +8 -0
  60. package/dist/components/icons/naver.js +10 -0
  61. package/dist/components/icons/notion.d.ts +8 -0
  62. package/dist/components/icons/notion.js +10 -0
  63. package/dist/components/icons/paybin.d.ts +7 -0
  64. package/dist/components/icons/paybin.js +9 -0
  65. package/dist/components/icons/paypal.d.ts +8 -0
  66. package/dist/components/icons/paypal.js +10 -0
  67. package/dist/components/icons/polar.d.ts +8 -0
  68. package/dist/components/icons/polar.js +10 -0
  69. package/dist/components/icons/railway.d.ts +8 -0
  70. package/dist/components/icons/railway.js +10 -0
  71. package/dist/components/icons/reddit.d.ts +8 -0
  72. package/dist/components/icons/reddit.js +10 -0
  73. package/dist/components/icons/roblox.d.ts +11 -0
  74. package/dist/components/icons/roblox.js +13 -0
  75. package/dist/components/icons/salesforce.d.ts +8 -0
  76. package/dist/components/icons/salesforce.js +10 -0
  77. package/dist/components/icons/slack.d.ts +8 -0
  78. package/dist/components/icons/slack.js +10 -0
  79. package/dist/components/icons/spotify.d.ts +8 -0
  80. package/dist/components/icons/spotify.js +10 -0
  81. package/dist/components/icons/tiktok.d.ts +9 -0
  82. package/dist/components/icons/tiktok.js +11 -0
  83. package/dist/components/icons/twitch.d.ts +8 -0
  84. package/dist/components/icons/twitch.js +13 -0
  85. package/dist/components/icons/vercel.d.ts +8 -0
  86. package/dist/components/icons/vercel.js +10 -0
  87. package/dist/components/icons/vk.d.ts +8 -0
  88. package/dist/components/icons/vk.js +10 -0
  89. package/dist/components/icons/wechat.d.ts +8 -0
  90. package/dist/components/icons/wechat.js +10 -0
  91. package/dist/components/icons/x.d.ts +8 -0
  92. package/dist/components/icons/x.js +10 -0
  93. package/dist/components/icons/zoom.d.ts +8 -0
  94. package/dist/components/icons/zoom.js +12 -0
  95. package/dist/components/settings/account/theme-preview.d.ts +3 -0
  96. package/dist/components/settings/account/theme-preview.js +10 -0
  97. package/dist/core.d.ts +1 -0
  98. package/dist/core.js +1 -0
  99. package/dist/hooks/auth/use-auth-mutation.d.ts +18 -0
  100. package/dist/hooks/auth/use-auth-mutation.js +10 -0
  101. package/dist/hooks/auth/use-auth-query.d.ts +24 -0
  102. package/dist/hooks/auth/use-auth-query.js +10 -0
  103. package/dist/hooks/auth/use-authenticate.d.ts +9 -0
  104. package/dist/hooks/auth/use-authenticate.js +28 -0
  105. package/dist/hooks/auth/use-forgot-password.d.ts +20 -0
  106. package/dist/hooks/auth/use-forgot-password.js +14 -0
  107. package/dist/hooks/auth/use-request-password-reset.d.ts +26 -0
  108. package/dist/hooks/auth/use-request-password-reset.js +14 -0
  109. package/dist/hooks/auth/use-reset-password.d.ts +40 -0
  110. package/dist/hooks/auth/use-reset-password.js +13 -0
  111. package/dist/hooks/auth/use-send-verification-email.d.ts +24 -0
  112. package/dist/hooks/auth/use-send-verification-email.js +13 -0
  113. package/dist/hooks/auth/use-session.d.ts +9 -0
  114. package/dist/hooks/auth/use-session.js +18 -0
  115. package/dist/hooks/auth/use-sign-in-email.d.ts +53 -0
  116. package/dist/hooks/auth/use-sign-in-email.js +24 -0
  117. package/dist/hooks/auth/use-sign-in-magic-link.d.ts +32 -0
  118. package/dist/hooks/auth/use-sign-in-magic-link.js +13 -0
  119. package/dist/hooks/auth/use-sign-in-social.d.ts +93 -0
  120. package/dist/hooks/auth/use-sign-in-social.js +13 -0
  121. package/dist/hooks/auth/use-sign-out.d.ts +19 -0
  122. package/dist/hooks/auth/use-sign-out.js +24 -0
  123. package/dist/hooks/auth/use-sign-up-email.d.ts +526 -0
  124. package/dist/hooks/auth/use-sign-up-email.js +24 -0
  125. package/dist/hooks/auth/use-user.d.ts +513 -0
  126. package/dist/hooks/auth/use-user.js +14 -0
  127. package/dist/hooks/settings/use-account-info.d.ts +17 -0
  128. package/dist/hooks/settings/use-account-info.js +25 -0
  129. package/dist/hooks/settings/use-change-email.d.ts +24 -0
  130. package/dist/hooks/settings/use-change-email.js +23 -0
  131. package/dist/hooks/settings/use-change-password.d.ts +54 -0
  132. package/dist/hooks/settings/use-change-password.js +11 -0
  133. package/dist/hooks/settings/use-delete-user.d.ts +42 -0
  134. package/dist/hooks/settings/use-delete-user.js +11 -0
  135. package/dist/hooks/settings/use-link-social.d.ts +46 -0
  136. package/dist/hooks/settings/use-link-social.js +10 -0
  137. package/dist/hooks/settings/use-list-accounts.d.ts +20 -0
  138. package/dist/hooks/settings/use-list-accounts.js +23 -0
  139. package/dist/hooks/settings/use-list-device-sessions.d.ts +11 -0
  140. package/dist/hooks/settings/use-list-device-sessions.js +22 -0
  141. package/dist/hooks/settings/use-list-sessions.d.ts +20 -0
  142. package/dist/hooks/settings/use-list-sessions.js +22 -0
  143. package/dist/hooks/settings/use-revoke-multi-session.d.ts +19 -0
  144. package/dist/hooks/settings/use-revoke-multi-session.js +20 -0
  145. package/dist/hooks/settings/use-revoke-session.d.ts +19 -0
  146. package/dist/hooks/settings/use-revoke-session.js +21 -0
  147. package/dist/hooks/settings/use-set-active-session.d.ts +37 -0
  148. package/dist/hooks/settings/use-set-active-session.js +28 -0
  149. package/dist/hooks/settings/use-unlink-account.d.ts +21 -0
  150. package/dist/hooks/settings/use-unlink-account.js +21 -0
  151. package/dist/hooks/settings/use-update-user.d.ts +11 -0
  152. package/dist/hooks/settings/use-update-user.js +29 -0
  153. package/dist/hooks/use-hydrated.d.ts +6 -0
  154. package/dist/hooks/use-hydrated.js +18 -0
  155. package/dist/index.d.ts +32 -0
  156. package/dist/index.js +33 -0
  157. package/dist/lib/auth-client.d.ts +1979 -0
  158. package/dist/lib/auth-client.js +5 -0
  159. package/dist/lib/auth-config.d.ts +43 -0
  160. package/dist/lib/auth-config.js +1 -0
  161. package/dist/lib/auth-context.d.ts +2 -0
  162. package/dist/lib/auth-context.js +3 -0
  163. package/dist/lib/auth-hook-options.d.ts +8 -0
  164. package/dist/lib/auth-hook-options.js +1 -0
  165. package/dist/lib/provider-icons.d.ts +13 -0
  166. package/dist/lib/provider-icons.js +48 -0
  167. package/dist/lib/utils.d.ts +2 -0
  168. package/dist/lib/utils.js +5 -0
  169. package/package.json +64 -0
  170. package/src/components/auth/auth-provider.tsx +82 -0
  171. package/src/components/email/email-changed.tsx +381 -0
  172. package/src/components/email/email-localization.tsx +33 -0
  173. package/src/components/email/email-styles.tsx +175 -0
  174. package/src/components/email/email-verification.tsx +350 -0
  175. package/src/components/email/index.ts +9 -0
  176. package/src/components/email/magic-link.tsx +349 -0
  177. package/src/components/email/new-device.tsx +452 -0
  178. package/src/components/email/otp-email.tsx +321 -0
  179. package/src/components/email/password-changed.tsx +380 -0
  180. package/src/components/email/reset-password.tsx +343 -0
  181. package/src/components/icons/apple.tsx +24 -0
  182. package/src/components/icons/atlassian.tsx +43 -0
  183. package/src/components/icons/cognito.tsx +25 -0
  184. package/src/components/icons/discord.tsx +24 -0
  185. package/src/components/icons/dropbox.tsx +24 -0
  186. package/src/components/icons/facebook.tsx +30 -0
  187. package/src/components/icons/figma.tsx +43 -0
  188. package/src/components/icons/github.tsx +26 -0
  189. package/src/components/icons/gitlab.tsx +36 -0
  190. package/src/components/icons/google.tsx +42 -0
  191. package/src/components/icons/huggingface.tsx +44 -0
  192. package/src/components/icons/index.ts +35 -0
  193. package/src/components/icons/kakao.tsx +26 -0
  194. package/src/components/icons/kick.tsx +30 -0
  195. package/src/components/icons/line.tsx +24 -0
  196. package/src/components/icons/linear.tsx +24 -0
  197. package/src/components/icons/linkedin.tsx +28 -0
  198. package/src/components/icons/microsoft.tsx +24 -0
  199. package/src/components/icons/naver.tsx +24 -0
  200. package/src/components/icons/notion.tsx +25 -0
  201. package/src/components/icons/paybin.tsx +37 -0
  202. package/src/components/icons/paypal.tsx +36 -0
  203. package/src/components/icons/polar.tsx +31 -0
  204. package/src/components/icons/railway.tsx +24 -0
  205. package/src/components/icons/reddit.tsx +25 -0
  206. package/src/components/icons/roblox.tsx +28 -0
  207. package/src/components/icons/salesforce.tsx +24 -0
  208. package/src/components/icons/slack.tsx +36 -0
  209. package/src/components/icons/spotify.tsx +24 -0
  210. package/src/components/icons/tiktok.tsx +32 -0
  211. package/src/components/icons/twitch.tsx +50 -0
  212. package/src/components/icons/vercel.tsx +21 -0
  213. package/src/components/icons/vk.tsx +24 -0
  214. package/src/components/icons/wechat.tsx +24 -0
  215. package/src/components/icons/x.tsx +24 -0
  216. package/src/components/icons/zoom.tsx +48 -0
  217. package/src/components/settings/account/theme-preview.tsx +271 -0
  218. package/src/core.ts +1 -0
  219. package/src/hooks/auth/use-auth-mutation.ts +56 -0
  220. package/src/hooks/auth/use-auth-query.ts +50 -0
  221. package/src/hooks/auth/use-authenticate.ts +35 -0
  222. package/src/hooks/auth/use-request-password-reset.ts +24 -0
  223. package/src/hooks/auth/use-reset-password.ts +23 -0
  224. package/src/hooks/auth/use-send-verification-email.ts +23 -0
  225. package/src/hooks/auth/use-session.ts +26 -0
  226. package/src/hooks/auth/use-sign-in-email.ts +35 -0
  227. package/src/hooks/auth/use-sign-in-magic-link.ts +23 -0
  228. package/src/hooks/auth/use-sign-in-social.ts +23 -0
  229. package/src/hooks/auth/use-sign-out.ts +34 -0
  230. package/src/hooks/auth/use-sign-up-email.ts +35 -0
  231. package/src/hooks/auth/use-user.ts +21 -0
  232. package/src/hooks/settings/use-account-info.ts +30 -0
  233. package/src/hooks/settings/use-change-email.ts +33 -0
  234. package/src/hooks/settings/use-change-password.ts +21 -0
  235. package/src/hooks/settings/use-delete-user.ts +21 -0
  236. package/src/hooks/settings/use-link-social.ts +19 -0
  237. package/src/hooks/settings/use-list-accounts.ts +27 -0
  238. package/src/hooks/settings/use-list-device-sessions.ts +32 -0
  239. package/src/hooks/settings/use-list-sessions.ts +26 -0
  240. package/src/hooks/settings/use-revoke-multi-session.ts +30 -0
  241. package/src/hooks/settings/use-revoke-session.ts +31 -0
  242. package/src/hooks/settings/use-set-active-session.ts +46 -0
  243. package/src/hooks/settings/use-unlink-account.ts +31 -0
  244. package/src/hooks/settings/use-update-user.ts +44 -0
  245. package/src/index.ts +34 -0
  246. package/src/lib/auth-client.ts +37 -0
  247. package/src/lib/auth-config.ts +48 -0
  248. package/src/lib/auth-context.ts +6 -0
  249. package/src/lib/provider-icons.ts +90 -0
  250. package/src/lib/utils.ts +6 -0
@@ -0,0 +1,32 @@
1
+ import type { ComponentPropsWithRef } from "react"
2
+
3
+ /**
4
+ * Renders the TikTok logo as an inline SVG.
5
+ *
6
+ * The component forwards received props to the root `<svg>` element.
7
+ *
8
+ * @returns The SVG element representing the TikTok logo.
9
+ */
10
+ export function TikTok(props: ComponentPropsWithRef<"svg">) {
11
+ return (
12
+ <svg
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ viewBox="0 0 256 290"
15
+ role="img"
16
+ aria-label="TikTok"
17
+ {...props}
18
+ >
19
+ <path
20
+ fill="#ff004f"
21
+ d="M189.72 104.421c18.678 13.345 41.56 21.197 66.273 21.197v-47.53a67 67 0 0 1-13.918-1.456v37.413c-24.711 0-47.59-7.851-66.272-21.195v96.996c0 48.523-39.356 87.855-87.9 87.855c-18.113 0-34.949-5.473-48.934-14.86c15.962 16.313 38.222 26.432 62.848 26.432c48.548 0 87.905-39.332 87.905-87.857v-96.995zm17.17-47.952c-9.546-10.423-15.814-23.893-17.17-38.785v-6.113h-13.189c3.32 18.927 14.644 35.097 30.358 44.898M69.673 225.607a40 40 0 0 1-8.203-24.33c0-22.192 18.001-40.186 40.21-40.186a40.3 40.3 0 0 1 12.197 1.883v-48.593c-4.61-.631-9.262-.9-13.912-.801v37.822a40.3 40.3 0 0 0-12.203-1.882c-22.208 0-40.208 17.992-40.208 40.187c0 15.694 8.997 29.281 22.119 35.9"
22
+ />
23
+
24
+ <path d="M175.803 92.849c18.683 13.344 41.56 21.195 66.272 21.195V76.631c-13.794-2.937-26.005-10.141-35.186-20.162c-15.715-9.802-27.038-25.972-30.358-44.898h-34.643v189.843c-.079 22.132-18.049 40.052-40.21 40.052c-13.058 0-24.66-6.221-32.007-15.86c-13.12-6.618-22.118-20.206-22.118-35.898c0-22.193 18-40.187 40.208-40.187c4.255 0 8.356.662 12.203 1.882v-37.822c-47.692.985-86.047 39.933-86.047 87.834c0 23.912 9.551 45.589 25.053 61.428c13.985 9.385 30.82 14.86 48.934 14.86c48.545 0 87.9-39.335 87.9-87.857z" />
25
+
26
+ <path
27
+ fill="#00f2ea"
28
+ d="M242.075 76.63V66.516a66.3 66.3 0 0 1-35.186-10.047a66.47 66.47 0 0 0 35.186 20.163M176.53 11.57a68 68 0 0 1-.728-5.457V0h-47.834v189.845c-.076 22.13-18.046 40.05-40.208 40.05a40.06 40.06 0 0 1-18.09-4.287c7.347 9.637 18.949 15.857 32.007 15.857c22.16 0 40.132-17.918 40.21-40.05V11.571zM99.966 113.58v-10.769a89 89 0 0 0-12.061-.818C39.355 101.993 0 141.327 0 189.845c0 30.419 15.467 57.227 38.971 72.996c-15.502-15.838-25.053-37.516-25.053-61.427c0-47.9 38.354-86.848 86.048-87.833"
29
+ />
30
+ </svg>
31
+ )
32
+ }
@@ -0,0 +1,50 @@
1
+ import type { ComponentPropsWithRef } from "react"
2
+
3
+ /**
4
+ * Renders the Twitch logo as an inline SVG element.
5
+ *
6
+ * @param props - Props spread onto the root `<svg>` element for customization (e.g., className, style, width, height, aria attributes).
7
+ * @returns The SVG element representing the Twitch logo.
8
+ */
9
+ export function Twitch(props: ComponentPropsWithRef<"svg">) {
10
+ return (
11
+ <svg
12
+ version="1.1"
13
+ viewBox="0 0 2400 2800"
14
+ x="0px"
15
+ xmlSpace="preserve"
16
+ xmlns="http://www.w3.org/2000/svg"
17
+ xmlnsXlink="http://www.w3.org/1999/xlink"
18
+ y="0px"
19
+ role="img"
20
+ aria-label="Twitch"
21
+ {...props}
22
+ >
23
+ <style type="text/css">
24
+ {`
25
+ .st0{fill:#FFFFFF}
26
+ .st1{fill:#9146FF}
27
+ `}
28
+ </style>
29
+
30
+ <g>
31
+ <polygon
32
+ className="st0"
33
+ points="2200,1300 1800,1700 1400,1700 1050,2050 1050,1700 600,1700 600,200 2200,200"
34
+ />
35
+
36
+ <g>
37
+ <g>
38
+ <path
39
+ className="st1"
40
+ d="M500,0L0,500v1800h600v500l500-500h400l900-900V0H500z M2200,1300l-400,400h-400l-350,350v-350H600V200h1600V1300z"
41
+ />
42
+
43
+ <rect className="st1" height="600" width="200" x="1700" y="550" />
44
+ <rect className="st1" height="600" width="200" x="1150" y="550" />
45
+ </g>
46
+ </g>
47
+ </g>
48
+ </svg>
49
+ )
50
+ }
@@ -0,0 +1,21 @@
1
+ import type { ComponentPropsWithRef } from "react"
2
+
3
+ /**
4
+ * Renders the Vercel logo as an SVG icon.
5
+ *
6
+ * @param props - Props forwarded to the root `<svg>` element (e.g., className, style, width, height, aria-*).
7
+ * @returns An SVG element representing the Vercel logo.
8
+ */
9
+ export function Vercel(props: ComponentPropsWithRef<"svg">) {
10
+ return (
11
+ <svg
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ viewBox="0 0 24 24"
14
+ role="img"
15
+ aria-label="Vercel"
16
+ {...props}
17
+ >
18
+ <path fill="currentColor" d="M23 21.648H1L12 2.352z"></path>
19
+ </svg>
20
+ )
21
+ }
@@ -0,0 +1,24 @@
1
+ import type { ComponentPropsWithRef } from "react"
2
+
3
+ /**
4
+ * Render the VK social icon as an SVG element.
5
+ *
6
+ * @param props - SVG attributes and ref forwarded to the root `<svg>` element
7
+ * @returns An `<svg>` element containing the VK icon path
8
+ */
9
+ export function VK(props: ComponentPropsWithRef<"svg">) {
10
+ return (
11
+ <svg
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ viewBox="0 0 576 512"
14
+ role="img"
15
+ aria-label="VK"
16
+ {...props}
17
+ >
18
+ <path
19
+ fill="#0076FF"
20
+ d="M545 117.7c3.7-12.5 0-21.7-17.8-21.7h-58.9c-15 0-21.9 7.9-25.6 16.7c0 0-30 73.1-72.4 120.5c-13.7 13.7-20 18.1-27.5 18.1c-3.7 0-9.4-4.4-9.4-16.9V117.7c0-15-4.2-21.7-16.6-21.7h-92.6c-9.4 0-15 7-15 13.5c0 14.2 21.2 17.5 23.4 57.5v86.8c0 19-3.4 22.5-10.9 22.5c-20 0-68.6-73.4-97.4-157.4c-5.8-16.3-11.5-22.9-26.6-22.9H38.8c-16.8 0-20.2 7.9-20.2 16.7c0 15.6 20 93.1 93.1 195.5C160.4 378.1 229 416 291.4 416c37.5 0 42.1-8.4 42.1-22.9c0-66.8-3.4-73.1 15.4-73.1c8.7 0 23.7 4.4 58.7 38.1c40 40 46.6 57.9 69 57.9h58.9c16.8 0 25.3-8.4 20.4-25c-11.2-34.9-86.9-106.7-90.3-111.5c-8.7-11.2-6.2-16.2 0-26.2c.1-.1 72-101.3 79.4-135.6"
21
+ />
22
+ </svg>
23
+ )
24
+ }
@@ -0,0 +1,24 @@
1
+ import type { ComponentPropsWithRef } from "react"
2
+
3
+ /**
4
+ * Renders an "X" icon as an SVG React component.
5
+ *
6
+ * @param props - Props to spread onto the underlying `svg` element (e.g., className, style, ref).
7
+ * @returns The SVG element representing the "X" icon with its path filled by `currentColor`.
8
+ */
9
+ export function WeChat(props: ComponentPropsWithRef<"svg">) {
10
+ return (
11
+ <svg
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ viewBox="0 0 24 24"
14
+ role="img"
15
+ aria-label="WeChat"
16
+ {...props}
17
+ >
18
+ <path
19
+ fill="currentColor"
20
+ d="M9.5 4C5.36 4 2 6.69 2 10c0 1.89 1.08 3.56 2.78 4.66L4 17l2.5-1.5c.89.31 1.87.5 2.91.5A5.2 5.2 0 0 1 9 14c0-3.31 3.13-6 7-6c.19 0 .38 0 .56.03C15.54 5.69 12.78 4 9.5 4m-3 2.5a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1m5 0a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1M16 9c-3.31 0-6 2.24-6 5s2.69 5 6 5c.67 0 1.31-.08 1.91-.25L20 20l-.62-1.87C20.95 17.22 22 15.71 22 14c0-2.76-2.69-5-6-5m-2 2.5a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1m4 0a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1"
21
+ ></path>
22
+ </svg>
23
+ )
24
+ }
@@ -0,0 +1,24 @@
1
+ import type { ComponentPropsWithRef } from "react"
2
+
3
+ /**
4
+ * Renders an "X" icon as an SVG React component.
5
+ *
6
+ * @param props - Props to spread onto the underlying `svg` element (e.g., className, style, ref).
7
+ * @returns The SVG element representing the "X" icon with its path filled by `currentColor`.
8
+ */
9
+ export function X(props: ComponentPropsWithRef<"svg">) {
10
+ return (
11
+ <svg
12
+ viewBox="0 0 512 512"
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ role="img"
15
+ aria-label="X"
16
+ {...props}
17
+ >
18
+ <path
19
+ d="M389.2 48h70.6L305.6 224.2L487 464H345L233.7 318.6L106.5 464H35.8l164.9-188.5L26.8 48h145.6l100.5 132.9zm-24.8 373.8h39.1L151.1 88h-42z"
20
+ fill="currentColor"
21
+ />
22
+ </svg>
23
+ )
24
+ }
@@ -0,0 +1,48 @@
1
+ import { type ComponentPropsWithRef, useId } from "react"
2
+
3
+ /**
4
+ * Renders a stylized "Zoom" SVG icon featuring a blue multi-stop gradient and a white interior highlight.
5
+ *
6
+ * @param props - Props are forwarded to the root `<svg>` element (e.g., className, style, width, height, aria-*).
7
+ * @returns The SVG element for the Zoom icon.
8
+ */
9
+ export function Zoom(props: ComponentPropsWithRef<"svg">) {
10
+ const gradientId = useId()
11
+ return (
12
+ <svg
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ viewBox="0 0 256 256"
15
+ role="img"
16
+ aria-label="Zoom"
17
+ {...props}
18
+ >
19
+ <defs>
20
+ <linearGradient
21
+ id={gradientId}
22
+ x1="23.666%"
23
+ x2="76.334%"
24
+ y1="95.612%"
25
+ y2="4.388%"
26
+ >
27
+ <stop offset="0%" stopColor="#0845bf"></stop>
28
+ <stop offset="19.11%" stopColor="#0950de"></stop>
29
+ <stop offset="38.23%" stopColor="#0b59f6"></stop>
30
+ <stop offset="50%" stopColor="#0b5cff"></stop>
31
+ <stop offset="67.32%" stopColor="#0e5efe"></stop>
32
+ <stop offset="77.74%" stopColor="#1665fc"></stop>
33
+ <stop offset="86.33%" stopColor="#246ff9"></stop>
34
+ <stop offset="93.88%" stopColor="#387ff4"></stop>
35
+ <stop offset="100%" stopColor="#4f90ee"></stop>
36
+ </linearGradient>
37
+ </defs>
38
+ <path
39
+ fill={`url(#${gradientId})`}
40
+ d="M256 128c0 13.568-1.024 27.136-3.328 40.192c-6.912 43.264-41.216 77.568-84.48 84.48C155.136 254.976 141.568 256 128 256s-27.136-1.024-40.192-3.328c-43.264-6.912-77.568-41.216-84.48-84.48C1.024 155.136 0 141.568 0 128s1.024-27.136 3.328-40.192c6.912-43.264 41.216-77.568 84.48-84.48C100.864 1.024 114.432 0 128 0s27.136 1.024 40.192 3.328c43.264 6.912 77.568 41.216 84.48 84.48C254.976 100.864 256 114.432 256 128"
41
+ ></path>
42
+ <path
43
+ fill="#fff"
44
+ d="M204.032 207.872H75.008c-8.448 0-16.64-4.608-20.48-12.032c-4.608-8.704-2.816-19.2 4.096-26.112l89.856-89.856H83.968c-17.664 0-32-14.336-32-32h118.784c8.448 0 16.64 4.608 20.48 12.032c4.608 8.704 2.816 19.2-4.096 26.112l-89.6 90.112h74.496c17.664 0 32 14.08 32 31.744"
45
+ ></path>
46
+ </svg>
47
+ )
48
+ }
@@ -0,0 +1,271 @@
1
+ export function ThemePreviewSystem(props: React.SVGProps<SVGSVGElement>) {
2
+ return (
3
+ <svg
4
+ fill="none"
5
+ viewBox="0 0 240 117"
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ role="img"
8
+ aria-label="System theme preview"
9
+ {...props}
10
+ >
11
+ <defs>
12
+ {/* Diagonal clip for light (top-left) */}
13
+ <clipPath id="systemDiagonalLight">
14
+ <polygon points="0,0 240,0 0,117" />
15
+ </clipPath>
16
+ {/* Diagonal clip for dark (bottom-right) */}
17
+ <clipPath id="systemDiagonalDark">
18
+ <polygon points="240,0 240,117 0,117" />
19
+ </clipPath>
20
+ </defs>
21
+
22
+ {/* Light side (top-left diagonal) */}
23
+ <g clipPath="url(#systemDiagonalLight)">
24
+ <path
25
+ d="M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z"
26
+ fill="white"
27
+ />
28
+ <path
29
+ d="M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z"
30
+ stroke="#E4E4E7"
31
+ />
32
+ <path
33
+ d="M32 48.5C32 45.4624 34.4624 43 37.5 43H67.5C70.5376 43 73 45.4624 73 48.5C73 51.5376 70.5376 54 67.5 54H37.5C34.4624 54 32 51.5376 32 48.5Z"
34
+ fill="#F4F4F5"
35
+ />
36
+ <path
37
+ d="M17 105C17 101.686 19.6863 99 23 99H67C70.3137 99 73 101.686 73 105C73 108.314 70.3137 111 67 111H23C19.6863 111 17 108.314 17 105Z"
38
+ fill="#F4F4F5"
39
+ />
40
+ <path
41
+ d="M88 25.5C88 22.4624 90.4624 20 93.5 20H207.5C210.538 20 213 22.4624 213 25.5C213 28.5376 210.538 31 207.5 31H93.5C90.4624 31 88 28.5376 88 25.5Z"
42
+ fill="#E4E4E7"
43
+ />
44
+ <path
45
+ d="M88 105C88 101.686 90.6863 99 94 99H189C192.314 99 195 101.686 195 105C195 108.314 192.314 111 189 111H94C90.6863 111 88 108.314 88 105Z"
46
+ fill="#F4F4F5"
47
+ />
48
+ <path
49
+ d="M88 51C88 46.5817 91.5817 43 96 43H221C225.418 43 229 46.5817 229 51V85C229 89.4183 225.418 93 221 93H96C91.5817 93 88 89.4183 88 85V51Z"
50
+ fill="#F4F4F5"
51
+ />
52
+ <path
53
+ d="M17 48.5C17 45.4624 19.4624 43 22.5 43C25.5376 43 28 45.4624 28 48.5C28 51.5376 25.5376 54 22.5 54C19.4624 54 17 51.5376 17 48.5Z"
54
+ fill="#F4F4F5"
55
+ />
56
+ <path
57
+ d="M17 66.5C17 63.4624 19.4624 61 22.5 61C25.5376 61 28 63.4624 28 66.5C28 69.5376 25.5376 72 22.5 72C19.4624 72 17 69.5376 17 66.5Z"
58
+ fill="#F4F4F5"
59
+ />
60
+ <path
61
+ d="M17 86.5C17 83.4624 19.4624 81 22.5 81C25.5376 81 28 83.4624 28 86.5V87.5C28 90.5376 25.5376 93 22.5 93C19.4624 93 17 90.5376 17 87.5V86.5Z"
62
+ fill="#F4F4F5"
63
+ />
64
+ <path
65
+ d="M32 25.5C32 22.4624 34.4624 20 37.5 20H67.5C70.5376 20 73 22.4624 73 25.5C73 28.5376 70.5376 31 67.5 31H37.5C34.4624 31 32 28.5376 32 25.5Z"
66
+ fill="#E4E4E7"
67
+ />
68
+ <path
69
+ d="M32 66.5C32 63.4624 34.4624 61 37.5 61H67.5C70.5376 61 73 63.4624 73 66.5C73 69.5376 70.5376 72 67.5 72H37.5C34.4624 72 32 69.5376 32 66.5Z"
70
+ fill="#F4F4F5"
71
+ />
72
+ <path
73
+ d="M32 87C32 83.6863 34.6863 81 38 81H67C70.3137 81 73 83.6863 73 87C73 90.3137 70.3137 93 67 93H38C34.6863 93 32 90.3137 32 87Z"
74
+ fill="#F4F4F5"
75
+ />
76
+ <circle cx="22.5" cy="25.5" fill="#E4E4E7" r="5.5" />
77
+ </g>
78
+
79
+ {/* Dark side (bottom-right diagonal) */}
80
+ <g clipPath="url(#systemDiagonalDark)">
81
+ <path
82
+ d="M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z"
83
+ fill="black"
84
+ />
85
+ <path
86
+ d="M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z"
87
+ stroke="#3F3F46"
88
+ />
89
+ <path
90
+ d="M32 48.5C32 45.4624 34.4624 43 37.5 43H67.5C70.5376 43 73 45.4624 73 48.5C73 51.5376 70.5376 54 67.5 54H37.5C34.4624 54 32 51.5376 32 48.5Z"
91
+ fill="#27272A"
92
+ />
93
+ <path
94
+ d="M17 105C17 101.686 19.6863 99 23 99H67C70.3137 99 73 101.686 73 105C73 108.314 70.3137 111 67 111H23C19.6863 111 17 108.314 17 105Z"
95
+ fill="#27272A"
96
+ />
97
+ <path
98
+ d="M88 25.5C88 22.4624 90.4624 20 93.5 20H207.5C210.538 20 213 22.4624 213 25.5C213 28.5376 210.538 31 207.5 31H93.5C90.4624 31 88 28.5376 88 25.5Z"
99
+ fill="#3F3F46"
100
+ />
101
+ <path
102
+ d="M88 105C88 101.686 90.6863 99 94 99H189C192.314 99 195 101.686 195 105C195 108.314 192.314 111 189 111H94C90.6863 111 88 108.314 88 105Z"
103
+ fill="#27272A"
104
+ />
105
+ <path
106
+ d="M88 51C88 46.5817 91.5817 43 96 43H221C225.418 43 229 46.5817 229 51V85C229 89.4183 225.418 93 221 93H96C91.5817 93 88 89.4183 88 85V51Z"
107
+ fill="#27272A"
108
+ />
109
+ <path
110
+ d="M17 48.5C17 45.4624 19.4624 43 22.5 43C25.5376 43 28 45.4624 28 48.5C28 51.5376 25.5376 54 22.5 54C19.4624 54 17 51.5376 17 48.5Z"
111
+ fill="#27272A"
112
+ />
113
+ <path
114
+ d="M17 66.5C17 63.4624 19.4624 61 22.5 61C25.5376 61 28 63.4624 28 66.5C28 69.5376 25.5376 72 22.5 72C19.4624 72 17 69.5376 17 66.5Z"
115
+ fill="#27272A"
116
+ />
117
+ <path
118
+ d="M17 86.5C17 83.4624 19.4624 81 22.5 81C25.5376 81 28 83.4624 28 86.5V87.5C28 90.5376 25.5376 93 22.5 93C19.4624 93 17 90.5376 17 87.5V86.5Z"
119
+ fill="#27272A"
120
+ />
121
+ <path
122
+ d="M32 25.5C32 22.4624 34.4624 20 37.5 20H67.5C70.5376 20 73 22.4624 73 25.5C73 28.5376 70.5376 31 67.5 31H37.5C34.4624 31 32 28.5376 32 25.5Z"
123
+ fill="#3F3F46"
124
+ />
125
+ <path
126
+ d="M32 66.5C32 63.4624 34.4624 61 37.5 61H67.5C70.5376 61 73 63.4624 73 66.5C73 69.5376 70.5376 72 67.5 72H37.5C34.4624 72 32 69.5376 32 66.5Z"
127
+ fill="#27272A"
128
+ />
129
+ <path
130
+ d="M32 87C32 83.6863 34.6863 81 38 81H67C70.3137 81 73 83.6863 73 87C73 90.3137 70.3137 93 67 93H38C34.6863 93 32 90.3137 32 87Z"
131
+ fill="#27272A"
132
+ />
133
+ <circle cx="22.5" cy="25.5" fill="#3F3F46" r="5.5" />
134
+ </g>
135
+ </svg>
136
+ )
137
+ }
138
+
139
+ export function ThemePreviewLight(props: React.SVGProps<SVGSVGElement>) {
140
+ return (
141
+ <svg
142
+ fill="none"
143
+ viewBox="0 0 240 117"
144
+ xmlns="http://www.w3.org/2000/svg"
145
+ role="img"
146
+ aria-label="Light"
147
+ {...props}
148
+ >
149
+ <path
150
+ d="M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z"
151
+ fill="white"
152
+ />
153
+ <path
154
+ d="M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z"
155
+ stroke="#E4E4E7"
156
+ />
157
+ <path
158
+ d="M32 48.5C32 45.4624 34.4624 43 37.5 43H67.5C70.5376 43 73 45.4624 73 48.5C73 51.5376 70.5376 54 67.5 54H37.5C34.4624 54 32 51.5376 32 48.5Z"
159
+ fill="#F4F4F5"
160
+ />
161
+ <path
162
+ d="M17 105C17 101.686 19.6863 99 23 99H67C70.3137 99 73 101.686 73 105C73 108.314 70.3137 111 67 111H23C19.6863 111 17 108.314 17 105Z"
163
+ fill="#F4F4F5"
164
+ />
165
+ <path
166
+ d="M88 25.5C88 22.4624 90.4624 20 93.5 20H207.5C210.538 20 213 22.4624 213 25.5C213 28.5376 210.538 31 207.5 31H93.5C90.4624 31 88 28.5376 88 25.5Z"
167
+ fill="#E4E4E7"
168
+ />
169
+ <path
170
+ d="M88 105C88 101.686 90.6863 99 94 99H189C192.314 99 195 101.686 195 105C195 108.314 192.314 111 189 111H94C90.6863 111 88 108.314 88 105Z"
171
+ fill="#F4F4F5"
172
+ />
173
+ <path
174
+ d="M88 51C88 46.5817 91.5817 43 96 43H221C225.418 43 229 46.5817 229 51V85C229 89.4183 225.418 93 221 93H96C91.5817 93 88 89.4183 88 85V51Z"
175
+ fill="#F4F4F5"
176
+ />
177
+ <path
178
+ d="M17 48.5C17 45.4624 19.4624 43 22.5 43C25.5376 43 28 45.4624 28 48.5C28 51.5376 25.5376 54 22.5 54C19.4624 54 17 51.5376 17 48.5Z"
179
+ fill="#F4F4F5"
180
+ />
181
+ <path
182
+ d="M17 66.5C17 63.4624 19.4624 61 22.5 61C25.5376 61 28 63.4624 28 66.5C28 69.5376 25.5376 72 22.5 72C19.4624 72 17 69.5376 17 66.5Z"
183
+ fill="#F4F4F5"
184
+ />
185
+ <path
186
+ d="M17 86.5C17 83.4624 19.4624 81 22.5 81C25.5376 81 28 83.4624 28 86.5V87.5C28 90.5376 25.5376 93 22.5 93C19.4624 93 17 90.5376 17 87.5V86.5Z"
187
+ fill="#F4F4F5"
188
+ />
189
+ <path
190
+ d="M32 25.5C32 22.4624 34.4624 20 37.5 20H67.5C70.5376 20 73 22.4624 73 25.5C73 28.5376 70.5376 31 67.5 31H37.5C34.4624 31 32 28.5376 32 25.5Z"
191
+ fill="#E4E4E7"
192
+ />
193
+ <path
194
+ d="M32 66.5C32 63.4624 34.4624 61 37.5 61H67.5C70.5376 61 73 63.4624 73 66.5C73 69.5376 70.5376 72 67.5 72H37.5C34.4624 72 32 69.5376 32 66.5Z"
195
+ fill="#F4F4F5"
196
+ />
197
+ <path
198
+ d="M32 87C32 83.6863 34.6863 81 38 81H67C70.3137 81 73 83.6863 73 87C73 90.3137 70.3137 93 67 93H38C34.6863 93 32 90.3137 32 87Z"
199
+ fill="#F4F4F5"
200
+ />
201
+ <circle cx="22.5" cy="25.5" fill="#E4E4E7" r="5.5" />
202
+ </svg>
203
+ )
204
+ }
205
+
206
+ export function ThemePreviewDark(props: React.SVGProps<SVGSVGElement>) {
207
+ return (
208
+ <svg
209
+ fill="none"
210
+ viewBox="0 0 240 117"
211
+ xmlns="http://www.w3.org/2000/svg"
212
+ role="img"
213
+ aria-label="Dark"
214
+ {...props}
215
+ >
216
+ <path
217
+ d="M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z"
218
+ fill="black"
219
+ />
220
+ <path
221
+ d="M12 0.5H228C234.351 0.5 239.5 5.64873 239.5 12V105C239.5 111.351 234.351 116.5 228 116.5H12C5.64873 116.5 0.5 111.351 0.5 105V12C0.5 5.64873 5.64873 0.5 12 0.5Z"
222
+ stroke="#3F3F46"
223
+ />
224
+ <path
225
+ d="M32 48.5C32 45.4624 34.4624 43 37.5 43H67.5C70.5376 43 73 45.4624 73 48.5C73 51.5376 70.5376 54 67.5 54H37.5C34.4624 54 32 51.5376 32 48.5Z"
226
+ fill="#27272A"
227
+ />
228
+ <path
229
+ d="M17 105C17 101.686 19.6863 99 23 99H67C70.3137 99 73 101.686 73 105C73 108.314 70.3137 111 67 111H23C19.6863 111 17 108.314 17 105Z"
230
+ fill="#27272A"
231
+ />
232
+ <path
233
+ d="M88 25.5C88 22.4624 90.4624 20 93.5 20H207.5C210.538 20 213 22.4624 213 25.5C213 28.5376 210.538 31 207.5 31H93.5C90.4624 31 88 28.5376 88 25.5Z"
234
+ fill="#3F3F46"
235
+ />
236
+ <path
237
+ d="M88 105C88 101.686 90.6863 99 94 99H189C192.314 99 195 101.686 195 105C195 108.314 192.314 111 189 111H94C90.6863 111 88 108.314 88 105Z"
238
+ fill="#27272A"
239
+ />
240
+ <path
241
+ d="M88 51C88 46.5817 91.5817 43 96 43H221C225.418 43 229 46.5817 229 51V85C229 89.4183 225.418 93 221 93H96C91.5817 93 88 89.4183 88 85V51Z"
242
+ fill="#27272A"
243
+ />
244
+ <path
245
+ d="M17 48.5C17 45.4624 19.4624 43 22.5 43C25.5376 43 28 45.4624 28 48.5C28 51.5376 25.5376 54 22.5 54C19.4624 54 17 51.5376 17 48.5Z"
246
+ fill="#27272A"
247
+ />
248
+ <path
249
+ d="M17 66.5C17 63.4624 19.4624 61 22.5 61C25.5376 61 28 63.4624 28 66.5C28 69.5376 25.5376 72 22.5 72C19.4624 72 17 69.5376 17 66.5Z"
250
+ fill="#27272A"
251
+ />
252
+ <path
253
+ d="M17 86.5C17 83.4624 19.4624 81 22.5 81C25.5376 81 28 83.4624 28 86.5V87.5C28 90.5376 25.5376 93 22.5 93C19.4624 93 17 90.5376 17 87.5V86.5Z"
254
+ fill="#27272A"
255
+ />
256
+ <path
257
+ d="M32 25.5C32 22.4624 34.4624 20 37.5 20H67.5C70.5376 20 73 22.4624 73 25.5C73 28.5376 70.5376 31 67.5 31H37.5C34.4624 31 32 28.5376 32 25.5Z"
258
+ fill="#3F3F46"
259
+ />
260
+ <path
261
+ d="M32 66.5C32 63.4624 34.4624 61 37.5 61H67.5C70.5376 61 73 63.4624 73 66.5C73 69.5376 70.5376 72 67.5 72H37.5C34.4624 72 32 69.5376 32 66.5Z"
262
+ fill="#27272A"
263
+ />
264
+ <path
265
+ d="M32 87C32 83.6863 34.6863 81 38 81H67C70.3137 81 73 83.6863 73 87C73 90.3137 70.3137 93 67 93H38C34.6863 93 32 90.3137 32 87Z"
266
+ fill="#27272A"
267
+ />
268
+ <circle cx="22.5" cy="25.5" fill="#3F3F46" r="5.5" />
269
+ </svg>
270
+ )
271
+ }
package/src/core.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "@better-auth-ui/core"
@@ -0,0 +1,56 @@
1
+ import {
2
+ type UseMutationOptions,
3
+ type UseMutationResult,
4
+ useMutation
5
+ } from "@tanstack/react-query"
6
+ import type { BetterFetchError } from "better-auth/react"
7
+
8
+ // biome-ignore lint/suspicious/noExplicitAny: any
9
+ type AuthFn = (...args: any) => Promise<any>
10
+
11
+ type MutationParams<TFn extends AuthFn> = undefined extends Parameters<TFn>[0]
12
+ ? // biome-ignore lint/suspicious/noConfusingVoidType: void is needed for mutations with optional params
13
+ void | Omit<NonNullable<Parameters<TFn>[0]>, "fetchOptions">
14
+ : Omit<Parameters<TFn>[0], "fetchOptions">
15
+
16
+ type InferMutationData<TFn extends AuthFn> = TFn extends (
17
+ ...args: infer _A
18
+ ) => infer R
19
+ ? Extract<Awaited<R>, { error: null }> extends { data: infer D }
20
+ ? D
21
+ : Awaited<R>
22
+ : Awaited<ReturnType<TFn>>
23
+
24
+ export type UseAuthMutationOptions<TFn extends AuthFn> = Omit<
25
+ UseMutationOptions<
26
+ InferMutationData<TFn>,
27
+ BetterFetchError,
28
+ MutationParams<TFn>
29
+ >,
30
+ "mutationFn"
31
+ >
32
+
33
+ export type UseAuthMutationResult<TFn extends AuthFn> = UseMutationResult<
34
+ InferMutationData<TFn>,
35
+ BetterFetchError,
36
+ MutationParams<TFn>
37
+ >
38
+
39
+ type UseAuthMutationProps<TFn extends AuthFn> = {
40
+ authFn: TFn
41
+ options?: UseAuthMutationOptions<TFn>
42
+ }
43
+
44
+ export function useAuthMutation<TFn extends AuthFn>({
45
+ authFn,
46
+ options
47
+ }: UseAuthMutationProps<TFn>): UseAuthMutationResult<TFn> {
48
+ return useMutation({
49
+ mutationFn: (params) =>
50
+ authFn({
51
+ ...params,
52
+ fetchOptions: { throw: true }
53
+ }),
54
+ ...options
55
+ })
56
+ }
@@ -0,0 +1,50 @@
1
+ import {
2
+ type UseQueryOptions,
3
+ type UseQueryResult,
4
+ useQuery
5
+ } from "@tanstack/react-query"
6
+ import type { BetterFetchError, BetterFetchOption } from "better-auth/react"
7
+
8
+ type BetterFetchFn = (options: {
9
+ fetchOptions?: BetterFetchOption
10
+ }) => Promise<{ data: unknown }>
11
+
12
+ type InferData<TFn> = TFn extends (options: {
13
+ fetchOptions?: BetterFetchOption
14
+ }) => Promise<{ data: infer TData }>
15
+ ? TData
16
+ : never
17
+
18
+ type OmitFetchOptions<T> = {
19
+ [K in keyof T as K extends "fetchOptions" ? never : K]: T[K]
20
+ }
21
+
22
+ export type UseAuthQueryOptions<TFn extends BetterFetchFn> = Omit<
23
+ UseQueryOptions<InferData<TFn>, BetterFetchError>,
24
+ "queryFn"
25
+ >
26
+
27
+ export type UseAuthQueryResult<TFn extends BetterFetchFn> = UseQueryResult<
28
+ InferData<TFn>,
29
+ BetterFetchError
30
+ >
31
+
32
+ type UseAuthQueryProps<TFn extends BetterFetchFn> = {
33
+ authFn: TFn
34
+ params?: OmitFetchOptions<Parameters<TFn>[0]>
35
+ options: UseAuthQueryOptions<TFn>
36
+ }
37
+
38
+ export function useAuthQuery<TFn extends BetterFetchFn>({
39
+ authFn,
40
+ params,
41
+ options
42
+ }: UseAuthQueryProps<TFn>) {
43
+ return useQuery<InferData<TFn>, BetterFetchError>({
44
+ queryFn: async () => {
45
+ const result = await authFn({ ...params, fetchOptions: { throw: true } })
46
+ return result as InferData<TFn>
47
+ },
48
+ ...options
49
+ })
50
+ }
@@ -0,0 +1,35 @@
1
+ import { type AuthClient, useAuth } from "@better-auth-ui/react"
2
+ import { useEffect } from "react"
3
+ import type { UseAuthQueryOptions, UseAuthQueryResult } from "./use-auth-query"
4
+ import { useSession } from "./use-session"
5
+
6
+ /**
7
+ * Redirects unauthenticated users to the sign-in page while preserving the current URL and exposes the active auth session state.
8
+ *
9
+ * @param options - Query options forwarded to the session query hook
10
+ * @returns An object containing `data` (the current session or `undefined`), `isPending` (whether the session query is in progress), and other session query state
11
+ */
12
+ export function useAuthenticate(
13
+ options?: Partial<UseAuthQueryOptions<AuthClient["getSession"]>>
14
+ ): UseAuthQueryResult<AuthClient["getSession"]> {
15
+ const { basePaths, viewPaths, navigate } = useAuth()
16
+ const session = useSession(options)
17
+
18
+ useEffect(() => {
19
+ if (session.data || session.isPending) return
20
+
21
+ const currentURL = window.location.pathname + window.location.search
22
+ const redirectTo = encodeURIComponent(currentURL)
23
+ const signInPath = `${basePaths.auth}/${viewPaths.auth.signIn}?redirectTo=${redirectTo}`
24
+
25
+ navigate({ to: signInPath, replace: true })
26
+ }, [
27
+ basePaths.auth,
28
+ session.data,
29
+ session.isPending,
30
+ viewPaths.auth.signIn,
31
+ navigate
32
+ ])
33
+
34
+ return session
35
+ }
@@ -0,0 +1,24 @@
1
+ import {
2
+ type AuthClient,
3
+ useAuth,
4
+ useAuthMutation
5
+ } from "@better-auth-ui/react"
6
+ import type { UseAuthMutationOptions } from "./use-auth-mutation"
7
+
8
+ export { useAuthMutation } from "./use-auth-mutation"
9
+
10
+ /**
11
+ * Hook that creates a mutation for the forgot-password flow.
12
+ *
13
+ * The mutation sends a password reset request for the submitted email,
14
+ * and navigates to the sign-in view on success.
15
+ *
16
+ * @returns The `useMutation` result.
17
+ */
18
+ export function useRequestPasswordReset(
19
+ options?: UseAuthMutationOptions<AuthClient["requestPasswordReset"]>
20
+ ) {
21
+ const { authClient } = useAuth()
22
+
23
+ return useAuthMutation({ authFn: authClient.requestPasswordReset, options })
24
+ }