react-query-firebase 2.14.0 → 3.0.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.
@@ -11,6 +11,7 @@ export * from "./useIdToken.js";
11
11
  export * from "./useReauthenticateWitCredentialMutation.js";
12
12
  export * from "./useReauthenticateWitRedirectMutation.js";
13
13
  export * from "./useAuthStateReady.js";
14
+ export * from "./useSignInWithCustomToken.js";
14
15
  export * from "./useSignInAnonymouslyMutation.js";
15
16
  export * from "./useEmailAuthProviderCredential.js";
16
17
  export * from "./useFacebookAuthProviderCredential.js";
@@ -11,6 +11,7 @@ export * from "./useIdToken.js";
11
11
  export * from "./useReauthenticateWitCredentialMutation.js";
12
12
  export * from "./useReauthenticateWitRedirectMutation.js";
13
13
  export * from "./useAuthStateReady.js";
14
+ export * from "./useSignInWithCustomToken.js";
14
15
  export * from "./useSignInAnonymouslyMutation.js";
15
16
  export * from "./useEmailAuthProviderCredential.js";
16
17
  export * from "./useFacebookAuthProviderCredential.js";
@@ -8,7 +8,7 @@ import { useAuth } from "./useAuth.js";
8
8
  */
9
9
  export const useCurrentUser = () => {
10
10
  const firebaseAuth = useAuth();
11
- const [currentUser, setCurrentUser] = useState(firebaseAuth.currentUser);
11
+ const [currentUser, setCurrentUser] = useState(firebaseAuth?.currentUser ?? null);
12
12
  useEffect(() => {
13
13
  const unsubscribe = onAuthStateChanged(firebaseAuth, (user) => {
14
14
  setCurrentUser(user);
@@ -7,7 +7,7 @@ export type UseSignInWithCredentialMutationVariables = {
7
7
  /**
8
8
  * Custom hook for handling sign in using credential
9
9
  * This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
10
- * @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
11
- * @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
10
+ * @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
11
+ * @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
12
12
  */
13
13
  export declare const useSignInWithCredentialMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>;
@@ -5,8 +5,8 @@ import { useAuth } from "./useAuth.js";
5
5
  /**
6
6
  * Custom hook for handling sign in using credential
7
7
  * This hook utilizes the `useMutation` mechanism to perform the sign-in operation.
8
- * @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
9
- * @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, FirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
8
+ * @param {Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional configurations for the mutation, omitting the mutationKey and mutationFn properties.
9
+ * @returns {UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, UseSignInWithCredentialMutationVariables, TContext>} The result object from the useMutation hook, containing the mutation function and its current state.
10
10
  */
11
11
  export const useSignInWithCredentialMutation = (options = {}) => {
12
12
  const auth = useAuth();
@@ -0,0 +1,40 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { FirebaseAuthTypes } from "@react-native-firebase/auth";
3
+ import { ReactNativeFirebase } from "@react-native-firebase/app";
4
+ /**
5
+ * @inline
6
+ */
7
+ export type UseSignInWithCustomTokenMutationOptions = {
8
+ /**
9
+ * Options for useMutation hook excluding mutationFn. MutationKey will be equal to reference.path by default.
10
+ */
11
+ options?: Omit<UseMutationOptions<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, {
12
+ customToken: string;
13
+ }>, "mutationFn">;
14
+ };
15
+ /**
16
+ * Executes a mutation and returns users credentials
17
+ *
18
+ * @group Hook
19
+ *
20
+ * @param {useSignInWithCustomTokenMutation} options - Configuration options for the mutation.
21
+ *
22
+ * @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
23
+ *
24
+ * @example
25
+ * ```jsx
26
+ * export const MyComponent = () => {
27
+ * const {mutate} = useSignInWithCustomTokenMutation({
28
+ * options: {
29
+ * },
30
+ * });
31
+ *
32
+ * // ....
33
+ * mutate();
34
+ * // ....
35
+ * };
36
+ * ```
37
+ */
38
+ export declare const useSignInWithCustomTokenMutation: ({ options }?: UseSignInWithCustomTokenMutationOptions) => import("@tanstack/react-query").UseMutationResult<FirebaseAuthTypes.UserCredential, ReactNativeFirebase.NativeFirebaseError, {
39
+ customToken: string;
40
+ }, unknown>;
@@ -0,0 +1,35 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { signInWithCustomToken } from "@react-native-firebase/auth";
3
+ import { useAuth } from "./useAuth.js";
4
+ import { SIGN_IN_ANONYMOUSLY_MUTATION_KEY } from "./mutation-keys.js";
5
+ /**
6
+ * Executes a mutation and returns users credentials
7
+ *
8
+ * @group Hook
9
+ *
10
+ * @param {useSignInWithCustomTokenMutation} options - Configuration options for the mutation.
11
+ *
12
+ * @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
13
+ *
14
+ * @example
15
+ * ```jsx
16
+ * export const MyComponent = () => {
17
+ * const {mutate} = useSignInWithCustomTokenMutation({
18
+ * options: {
19
+ * },
20
+ * });
21
+ *
22
+ * // ....
23
+ * mutate();
24
+ * // ....
25
+ * };
26
+ * ```
27
+ */
28
+ export const useSignInWithCustomTokenMutation = ({ options = {} } = {}) => {
29
+ const firebaseAuth = useAuth();
30
+ return useMutation({
31
+ ...options,
32
+ mutationKey: SIGN_IN_ANONYMOUSLY_MUTATION_KEY,
33
+ mutationFn: async ({ customToken }) => signInWithCustomToken(firebaseAuth, customToken)
34
+ });
35
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./react-native/index.js";
2
+ export * from "./types/index.js";
@@ -0,0 +1,2 @@
1
+ export * from "./react-native/index.js";
2
+ export * from "./types/index.js";
@@ -12,6 +12,7 @@ export * from "./useIdToken.js";
12
12
  export * from "./useReauthenticateWitCredentialMutation.js";
13
13
  export * from "./useReauthenticateWitRedirectMutation.js";
14
14
  export * from "./useSignInAnonymouslyMutation.js";
15
+ export * from "./useSignInWithCustomToken.js";
15
16
  export * from "./useEmailAuthProviderCredential.js";
16
17
  export * from "./useFacebookAuthProviderCredential.js";
17
18
  export * from "./useAppleAuthProviderCredential.js";
@@ -12,6 +12,7 @@ export * from "./useIdToken.js";
12
12
  export * from "./useReauthenticateWitCredentialMutation.js";
13
13
  export * from "./useReauthenticateWitRedirectMutation.js";
14
14
  export * from "./useSignInAnonymouslyMutation.js";
15
+ export * from "./useSignInWithCustomToken.js";
15
16
  export * from "./useEmailAuthProviderCredential.js";
16
17
  export * from "./useFacebookAuthProviderCredential.js";
17
18
  export * from "./useAppleAuthProviderCredential.js";
@@ -8,7 +8,7 @@ import { useAuth } from "./useAuth.js";
8
8
  */
9
9
  export const useCurrentUser = () => {
10
10
  const firebaseAuth = useAuth();
11
- const [currentUser, setCurrentUser] = useState(firebaseAuth.currentUser);
11
+ const [currentUser, setCurrentUser] = useState(firebaseAuth?.currentUser ?? null);
12
12
  useEffect(() => {
13
13
  const unsubscribe = onAuthStateChanged(firebaseAuth, (user) => {
14
14
  setCurrentUser(user);
@@ -0,0 +1,40 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { UserCredential } from "firebase/auth";
3
+ import { FirebaseError } from "firebase/app";
4
+ /**
5
+ * @inline
6
+ */
7
+ export type UseSignInWithCustomTokenMutationOptions = {
8
+ /**
9
+ * Options for useMutation hook excluding mutationFn. MutationKey will be equal to reference.path by default.
10
+ */
11
+ options?: Omit<UseMutationOptions<UserCredential, FirebaseError, {
12
+ customToken: string;
13
+ }>, "mutationFn">;
14
+ };
15
+ /**
16
+ * Executes a mutation and returns users credentials
17
+ *
18
+ * @group Hook
19
+ *
20
+ * @param {useSignInWithCustomTokenMutation} options - Configuration options for the mutation.
21
+ *
22
+ * @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
23
+ *
24
+ * @example
25
+ * ```jsx
26
+ * export const MyComponent = () => {
27
+ * const {mutate} = useSignInWithCustomTokenMutation({
28
+ * options: {
29
+ * },
30
+ * });
31
+ *
32
+ * // ....
33
+ * mutate();
34
+ * // ....
35
+ * };
36
+ * ```
37
+ */
38
+ export declare const useSignInWithCustomTokenMutation: ({ options }?: UseSignInWithCustomTokenMutationOptions) => import("@tanstack/react-query").UseMutationResult<UserCredential, FirebaseError, {
39
+ customToken: string;
40
+ }, unknown>;
@@ -0,0 +1,35 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { signInWithCustomToken } from "firebase/auth";
3
+ import { useAuth } from "./useAuth.js";
4
+ import { SIGN_IN_ANONYMOUSLY_MUTATION_KEY } from "./mutation-keys.js";
5
+ /**
6
+ * Executes a mutation and returns users credentials
7
+ *
8
+ * @group Hook
9
+ *
10
+ * @param {useSignInWithCustomTokenMutation} options - Configuration options for the mutation.
11
+ *
12
+ * @returns {UseMutationResult<AppModelType, Error, UseAddDocMutationValues<AppModelType>, TContext>} A mutation result
13
+ *
14
+ * @example
15
+ * ```jsx
16
+ * export const MyComponent = () => {
17
+ * const {mutate} = useSignInWithCustomTokenMutation({
18
+ * options: {
19
+ * },
20
+ * });
21
+ *
22
+ * // ....
23
+ * mutate();
24
+ * // ....
25
+ * };
26
+ * ```
27
+ */
28
+ export const useSignInWithCustomTokenMutation = ({ options = {} } = {}) => {
29
+ const firebaseAuth = useAuth();
30
+ return useMutation({
31
+ ...options,
32
+ mutationKey: SIGN_IN_ANONYMOUSLY_MUTATION_KEY,
33
+ mutationFn: async ({ customToken }) => signInWithCustomToken(firebaseAuth, customToken)
34
+ });
35
+ };
package/dist/web.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./web/index.js";
2
+ export * from "./types/index.js";
package/dist/web.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./web/index.js";
2
+ export * from "./types/index.js";
package/package.json CHANGED
@@ -29,17 +29,17 @@
29
29
  "@react-native-firebase/firestore": "^23.7.0",
30
30
  "@react-native-firebase/installations": "^23.7.0",
31
31
  "@react-native-firebase/remote-config": "^23.7.0",
32
- "@tanstack/react-query": "^5.90.12",
32
+ "@tanstack/react-query": "^5.90.15",
33
33
  "@types/react": "^19.2.7",
34
- "eslint": "^9.39.1",
34
+ "eslint": "^9.39.2",
35
35
  "eslint-config-prettier": "^10.1.8",
36
36
  "eslint-plugin-import": "^2.32.0",
37
- "eslint-plugin-jest": "^29.2.1",
37
+ "eslint-plugin-jest": "^29.11.2",
38
38
  "eslint-plugin-jsonc": "^2.21.0",
39
39
  "eslint-plugin-prettier": "^5.5.4",
40
40
  "eslint-plugin-react": "^7.37.5",
41
41
  "eslint-plugin-react-hooks": "^7.0.1",
42
- "firebase": "^12.5.0",
42
+ "firebase": "^12.7.0",
43
43
  "husky": "^9.1.7",
44
44
  "lint-staged": "^16.2.7",
45
45
  "prettier": "^3.7.4",
@@ -48,7 +48,7 @@
48
48
  "typedoc-plugin-markdown": "^4.9.0",
49
49
  "typedoc-vitepress-theme": "^1.1.2",
50
50
  "typescript": "^5.9.3",
51
- "typescript-eslint": "^8.49.0",
51
+ "typescript-eslint": "^8.51.0",
52
52
  "vitepress": "^1.6.4"
53
53
  },
54
54
  "homepage": "https://github.com/vpishuk/react-query-firebase",
@@ -66,24 +66,11 @@
66
66
  },
67
67
  "exports": {
68
68
  ".": {
69
- "import": "./dist/index.js",
70
- "require": "./dist/index.js",
71
- "types": "./dist/index.d.ts"
72
- },
73
- "./react-native": {
74
- "import": "./dist/react-native/index.js",
75
- "require": "./dist/react-native/index.js",
76
- "types": "./dist/react-native/index.d.ts"
77
- },
78
- "./web": {
79
- "import": "./dist/web/index.js",
80
- "require": "./dist/web/index.js",
81
- "types": "./dist/web/index.d.ts"
82
- },
83
- "./types": {
84
- "import": "./dist/types/index.js",
85
- "require": "./dist/types/index.js",
86
- "types": "./dist/types/index.d.ts"
69
+ "browser": "./dist/web.js",
70
+ "react-native": "./dist/react-native.js",
71
+ "import": "./dist/web.js",
72
+ "require": "./dist/web.js",
73
+ "types": "./dist/web.d.ts"
87
74
  }
88
75
  },
89
76
  "files": [
@@ -104,5 +91,5 @@
104
91
  "docs:build": "vitepress build docs",
105
92
  "docs:preview": "vitepress preview docs"
106
93
  },
107
- "version": "2.14.0"
94
+ "version": "3.0.0"
108
95
  }
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * as RN from "./react-native/index.js";
2
- export * as Web from "./web/index.js";
package/dist/index.js DELETED
@@ -1,4 +0,0 @@
1
- import * as RN_1 from "./react-native/index.js";
2
- export { RN_1 as RN };
3
- import * as Web_1 from "./web/index.js";
4
- export { Web_1 as Web };