@better-auth-ui/react 1.6.0 → 1.6.1

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.
@@ -1,4 +1,5 @@
1
- import { useAuth, useAuthMutation, useSession } from "@better-auth-ui/react";
1
+ import { useAuth, useAuthMutation } from "@better-auth-ui/react";
2
+ import { useQueryClient } from "@tanstack/react-query";
2
3
  export { useAuthMutation } from "./use-auth-mutation";
3
4
  /**
4
5
  * Hook that creates a mutation for email/password sign-in.
@@ -10,13 +11,13 @@ export { useAuthMutation } from "./use-auth-mutation";
10
11
  */
11
12
  export function useSignInEmail(options) {
12
13
  const { authClient } = useAuth();
13
- const { refetch } = useSession({ refetchOnMount: false });
14
+ const queryClient = useQueryClient();
14
15
  return useAuthMutation({
15
16
  authFn: authClient.signIn.email,
16
17
  options: {
17
18
  ...options,
18
19
  onSuccess: async (...args) => {
19
- await refetch();
20
+ queryClient.resetQueries({ queryKey: ["auth", "getSession"] });
20
21
  await options?.onSuccess?.(...args);
21
22
  }
22
23
  }
@@ -0,0 +1,58 @@
1
+ import type { AuthClient } from "../../lib/auth-client";
2
+ import { type UseAuthMutationOptions } from "./use-auth-mutation";
3
+ /**
4
+ * Hook that creates a mutation for passkey sign-in.
5
+ *
6
+ * The mutation sends a passkey sign-in request and
7
+ * refetches the session on completion.
8
+ *
9
+ * @returns The `useMutation` result.
10
+ */
11
+ export declare function useSignInPasskey(options?: UseAuthMutationOptions<AuthClient["signIn"]["passkey"]>): import("./use-auth-mutation").UseAuthMutationResult<(opts?: {
12
+ autoFill?: boolean;
13
+ extensions?: import("@better-auth/passkey/client").AuthenticationExtensionsClientInputs;
14
+ returnWebAuthnResponse?: boolean;
15
+ fetchOptions?: import("better-auth").ClientFetchOption;
16
+ } | undefined, options?: import("better-auth").ClientFetchOption | undefined) => Promise<{
17
+ data: null;
18
+ error: {
19
+ message?: string | undefined;
20
+ status: number;
21
+ statusText: string;
22
+ };
23
+ } | {
24
+ data: {
25
+ session: import("better-auth").Session;
26
+ user: import("better-auth").User;
27
+ };
28
+ error: null;
29
+ } | {
30
+ webauthn: {
31
+ response: import("@better-auth/passkey/client").AuthenticationResponseJSON;
32
+ clientExtensionResults: import("@better-auth/passkey/client").AuthenticationExtensionsClientOutputs;
33
+ };
34
+ data: null;
35
+ error: {
36
+ message?: string | undefined;
37
+ status: number;
38
+ statusText: string;
39
+ };
40
+ } | {
41
+ webauthn: {
42
+ response: import("@better-auth/passkey/client").AuthenticationResponseJSON;
43
+ clientExtensionResults: import("@better-auth/passkey/client").AuthenticationExtensionsClientOutputs;
44
+ };
45
+ data: {
46
+ session: import("better-auth").Session;
47
+ user: import("better-auth").User;
48
+ };
49
+ error: null;
50
+ } | {
51
+ data: null;
52
+ error: {
53
+ code: string;
54
+ message: string;
55
+ status: number;
56
+ statusText: string;
57
+ };
58
+ }>>;
@@ -0,0 +1,25 @@
1
+ import { useQueryClient } from "@tanstack/react-query";
2
+ import { useAuth } from "../../components/auth/auth-provider";
3
+ import { useAuthMutation } from "./use-auth-mutation";
4
+ /**
5
+ * Hook that creates a mutation for passkey sign-in.
6
+ *
7
+ * The mutation sends a passkey sign-in request and
8
+ * refetches the session on completion.
9
+ *
10
+ * @returns The `useMutation` result.
11
+ */
12
+ export function useSignInPasskey(options) {
13
+ const { authClient } = useAuth();
14
+ const queryClient = useQueryClient();
15
+ return useAuthMutation({
16
+ authFn: authClient.signIn.passkey,
17
+ options: {
18
+ ...options,
19
+ onSuccess: async (...args) => {
20
+ queryClient.resetQueries({ queryKey: ["auth", "getSession"] });
21
+ await options?.onSuccess?.(...args);
22
+ }
23
+ }
24
+ });
25
+ }