react-query-firebase 2.8.0 → 2.9.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.
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "@react-native-firebase/firestore": "^22.x.x",
13
13
  "@react-native-firebase/installations": "^22.x.x",
14
14
  "@react-native-firebase/remote-config": "^22.x.x",
15
- "@tanstack/react-query": "^5.x.x",
15
+ "@tanstack/react-query": "^5.83.0",
16
16
  "firebase": "^11.x.x",
17
17
  "react": "^18.x.x || ^19.x.x"
18
18
  },
@@ -24,22 +24,22 @@
24
24
  "@laverve/eslint-utils": "^5.3.1",
25
25
  "@react-native-firebase/analytics": "^22.2.1",
26
26
  "@react-native-firebase/app": "^22.2.1",
27
- "@react-native-firebase/auth": "^22.2.1",
28
- "@react-native-firebase/crashlytics": "^22.2.1",
29
- "@react-native-firebase/firestore": "^22.2.1",
30
- "@react-native-firebase/installations": "^22.2.1",
31
- "@react-native-firebase/remote-config": "^22.2.1",
32
- "@types/react": "^19.1.7",
27
+ "@react-native-firebase/auth": "^22.4.0",
28
+ "@react-native-firebase/crashlytics": "^22.4.0",
29
+ "@react-native-firebase/firestore": "^22.4.0",
30
+ "@react-native-firebase/installations": "^22.4.0",
31
+ "@react-native-firebase/remote-config": "^22.4.0",
32
+ "@types/react": "^19.1.8",
33
+ "firebase": "^11.9.0",
33
34
  "husky": "^9.1.7",
34
- "lint-staged": "^16.1.0",
35
- "prettier": "^3.5.3",
35
+ "lint-staged": "^16.1.2",
36
+ "prettier": "^3.6.2",
36
37
  "react": "^19.1.0",
37
- "typedoc": "^0.28.5",
38
- "typedoc-plugin-markdown": "^4.6.4",
38
+ "typedoc": "^0.28.7",
39
+ "typedoc-plugin-markdown": "^4.7.1",
39
40
  "typedoc-vitepress-theme": "^1.1.2",
40
41
  "typescript": "^5.8.3",
41
- "vitepress": "^1.6.3",
42
- "firebase": "^11.9.0"
42
+ "vitepress": "^1.6.3"
43
43
  },
44
44
  "homepage": "https://github.com/vpishuk/react-query-firebase",
45
45
  "keywords": [
@@ -74,5 +74,5 @@
74
74
  "docs:build": "vitepress build docs",
75
75
  "docs:preview": "vitepress preview docs"
76
76
  },
77
- "version": "2.8.0"
77
+ "version": "2.9.1"
78
78
  }
@@ -14,4 +14,5 @@ export * from "./useAuthStateReady";
14
14
  export * from "./useSignInAnonymouslyMutation";
15
15
  export * from "./useEmailAuthProviderCredential";
16
16
  export * from "./useFacebookAuthProviderCredential";
17
+ export * from "./useAppleAuthProviderCredential";
17
18
  export * from "./useLinkWithCredentialMutation";
@@ -14,4 +14,5 @@ export * from "./useAuthStateReady";
14
14
  export * from "./useSignInAnonymouslyMutation";
15
15
  export * from "./useEmailAuthProviderCredential";
16
16
  export * from "./useFacebookAuthProviderCredential";
17
+ export * from "./useAppleAuthProviderCredential";
17
18
  export * from "./useLinkWithCredentialMutation";
@@ -14,4 +14,5 @@ export * from "./useAuthStateReady";
14
14
  export * from "./useSignInAnonymouslyMutation";
15
15
  export * from "./useEmailAuthProviderCredential";
16
16
  export * from "./useFacebookAuthProviderCredential";
17
+ export * from "./useAppleAuthProviderCredential";
17
18
  export * from "./useLinkWithCredentialMutation";
@@ -0,0 +1,24 @@
1
+ import { FirebaseAuthTypes } from "@react-native-firebase/auth";
2
+ type Credential = {
3
+ token: string;
4
+ nonce: string;
5
+ };
6
+ /**
7
+ * A custom hook that returns an auth credential for facebook.
8
+ *
9
+ * @group Hook
10
+ * @param {AuthProvider} provider alas of a provider
11
+ *
12
+ * @returns {AuthCredential}
13
+ *
14
+ * @example
15
+ * ```jsx
16
+ * export const MyComponent = () => {
17
+ * const getCredential = useAppleAuthProviderCredential();
18
+ * // ...
19
+ * getCredential({token, nonce: ''})
20
+ * };
21
+ * ```
22
+ */
23
+ export declare const useAppleAuthProviderCredential: () => (credential: Credential) => FirebaseAuthTypes.AuthCredential;
24
+ export {};
@@ -0,0 +1,24 @@
1
+ import { AppleAuthProvider } from "@react-native-firebase/auth";
2
+ import { useCallback } from "react";
3
+ /**
4
+ * A custom hook that returns an auth credential for facebook.
5
+ *
6
+ * @group Hook
7
+ * @param {AuthProvider} provider alas of a provider
8
+ *
9
+ * @returns {AuthCredential}
10
+ *
11
+ * @example
12
+ * ```jsx
13
+ * export const MyComponent = () => {
14
+ * const getCredential = useAppleAuthProviderCredential();
15
+ * // ...
16
+ * getCredential({token, nonce: ''})
17
+ * };
18
+ * ```
19
+ */
20
+ export const useAppleAuthProviderCredential = () => {
21
+ return useCallback((credential) => {
22
+ return AppleAuthProvider.credential(credential.token, credential.nonce);
23
+ }, []);
24
+ };
@@ -0,0 +1,31 @@
1
+ import { AppleAuthProvider, FirebaseAuthTypes } from "@react-native-firebase/auth";
2
+ import { useCallback } from "react";
3
+
4
+ type Credential = {
5
+ token: string;
6
+ nonce: string;
7
+ };
8
+
9
+ /**
10
+ * A custom hook that returns an auth credential for facebook.
11
+ *
12
+ * @group Hook
13
+ * @param {AuthProvider} provider alas of a provider
14
+ *
15
+ * @returns {AuthCredential}
16
+ *
17
+ * @example
18
+ * ```jsx
19
+ * export const MyComponent = () => {
20
+ * const getCredential = useAppleAuthProviderCredential();
21
+ * // ...
22
+ * getCredential({token, nonce: ''})
23
+ * };
24
+ * ```
25
+ */
26
+
27
+ export const useAppleAuthProviderCredential = () => {
28
+ return useCallback((credential: Credential): FirebaseAuthTypes.AuthCredential => {
29
+ return AppleAuthProvider.credential(credential.token, credential.nonce);
30
+ }, []);
31
+ };
@@ -1,3 +1,4 @@
1
+ import { onAuthStateChanged } from "@react-native-firebase/auth";
1
2
  import { useAuth } from "./useAuth";
2
3
  import { useEffect, useState } from "react";
3
4
  /**
@@ -20,7 +21,7 @@ export const useAuthStateReady = () => {
20
21
  const firebaseAuth = useAuth();
21
22
  const [isAuthStateReady, setIsAuthStateReady] = useState(false);
22
23
  useEffect(() => {
23
- const subscription = firebaseAuth.onAuthStateChanged(() => {
24
+ const subscription = onAuthStateChanged(firebaseAuth, () => {
24
25
  if (!isAuthStateReady) {
25
26
  setIsAuthStateReady(true);
26
27
  }
@@ -1,3 +1,4 @@
1
+ import { onAuthStateChanged } from "@react-native-firebase/auth";
1
2
  import { useAuth } from "./useAuth";
2
3
  import { useEffect, useState } from "react";
3
4
 
@@ -23,7 +24,7 @@ export const useAuthStateReady = () => {
23
24
  const [isAuthStateReady, setIsAuthStateReady] = useState(false);
24
25
 
25
26
  useEffect(() => {
26
- const subscription = firebaseAuth.onAuthStateChanged(() => {
27
+ const subscription = onAuthStateChanged(firebaseAuth, () => {
27
28
  if (!isAuthStateReady) {
28
29
  setIsAuthStateReady(true);
29
30
  }
@@ -72,9 +72,9 @@ export const useAddDocMutation = <AppModelType extends AppModel = AppModel, TCon
72
72
  mutationKey,
73
73
  ...options,
74
74
  mutationFn: async ({ data }) => {
75
- const docRef = await addDoc<AppModelType>(collectionReference, data);
75
+ const docRef = await addDoc<AppModelType, AppModelType>(collectionReference, data);
76
76
  const docSnap = await getDoc(docRef);
77
- return { ...docSnap.data(), uid: docRef.id } as AppModelType;
77
+ return { ...(docSnap.data() as AppModelType), uid: docRef.id } as AppModelType;
78
78
  }
79
79
  });
80
80
  };
@@ -73,7 +73,7 @@ export const useCountQuery = <AppModelType extends AppModel = AppModel>({
73
73
  queryFn: async () => {
74
74
  const queryToExecute = compositeFilter
75
75
  ? query(collectionReference, compositeFilter, ...(queryConstraints as QueryNonFilterConstraint[]))
76
- : query(collectionReference, ...queryConstraints);
76
+ : query(collectionReference, ...(queryConstraints as QueryConstraint[]));
77
77
 
78
78
  const querySnapshot = await getCountFromServer(queryToExecute);
79
79
  if (querySnapshot) {
@@ -96,9 +96,12 @@ export const useInfiniteQuery = <AppModelType extends AppModel = AppModel, TQuer
96
96
  const allQueryConstraints = [...queryConstraints, ...(pageParam ? [pageParam] : [])];
97
97
  const queryToExecute = compositeFilter
98
98
  ? query(collectionReference, compositeFilter, ...(allQueryConstraints as QueryNonFilterConstraint[]))
99
- : query(collectionReference, ...allQueryConstraints);
99
+ : query(collectionReference, ...(allQueryConstraints as QueryConstraint[]));
100
100
 
101
- const querySnapshot = await getDocs(queryToExecute);
101
+ const querySnapshot: FirebaseFirestoreTypes.QuerySnapshot<AppModelType> = await getDocs<
102
+ AppModelType,
103
+ AppModelType
104
+ >(queryToExecute);
102
105
  const docs: AppModelType[] = [];
103
106
 
104
107
  if (querySnapshot) {
@@ -73,9 +73,9 @@ export const useQuery = <AppModelType extends AppModel = AppModel>({
73
73
  queryFn: async () => {
74
74
  const queryToExecute = compositeFilter
75
75
  ? query(collectionReference, compositeFilter, ...(queryConstraints as QueryNonFilterConstraint[]))
76
- : query(collectionReference, ...queryConstraints);
76
+ : query(collectionReference, ...(queryConstraints as QueryConstraint[]));
77
77
 
78
- const querySnapshot = await getDocs(queryToExecute);
78
+ const querySnapshot: FirebaseFirestoreTypes.QuerySnapshot<AppModelType> = await getDocs(queryToExecute);
79
79
  const docs: AppModelType[] = [];
80
80
 
81
81
  if (querySnapshot) {
@@ -14,4 +14,5 @@ export * from "./useReauthenticateWitRedirectMutation";
14
14
  export * from "./useSignInAnonymouslyMutation";
15
15
  export * from "./useEmailAuthProviderCredential";
16
16
  export * from "./useFacebookAuthProviderCredential";
17
+ export * from "./useAppleAuthProviderCredential";
17
18
  export * from "./useLinkWithCredentialMutation";
package/web/auth/index.js CHANGED
@@ -14,4 +14,5 @@ export * from "./useReauthenticateWitRedirectMutation";
14
14
  export * from "./useSignInAnonymouslyMutation";
15
15
  export * from "./useEmailAuthProviderCredential";
16
16
  export * from "./useFacebookAuthProviderCredential";
17
+ export * from "./useAppleAuthProviderCredential";
17
18
  export * from "./useLinkWithCredentialMutation";
package/web/auth/index.ts CHANGED
@@ -14,4 +14,5 @@ export * from "./useReauthenticateWitRedirectMutation";
14
14
  export * from "./useSignInAnonymouslyMutation";
15
15
  export * from "./useEmailAuthProviderCredential";
16
16
  export * from "./useFacebookAuthProviderCredential";
17
+ export * from "./useAppleAuthProviderCredential";
17
18
  export * from "./useLinkWithCredentialMutation";
@@ -0,0 +1,24 @@
1
+ import { AuthCredential } from "firebase/auth";
2
+ type Credential = {
3
+ token: string;
4
+ nonce: string;
5
+ };
6
+ /**
7
+ * A custom hook that returns an auth credential for facebook.
8
+ *
9
+ * @group Hook
10
+ * @param {AuthProvider} provider alas of a provider
11
+ *
12
+ * @returns {AuthCredential}
13
+ *
14
+ * @example
15
+ * ```jsx
16
+ * export const MyComponent = () => {
17
+ * const getCredential = useAppleAuthProviderCredential();
18
+ * // ...
19
+ * getCredential({token, nonce: ''})
20
+ * };
21
+ * ```
22
+ */
23
+ export declare const useAppleAuthProviderCredential: () => (credential: Credential) => AuthCredential;
24
+ export {};
@@ -0,0 +1,25 @@
1
+ import { OAuthProvider } from "firebase/auth";
2
+ import { useCallback } from "react";
3
+ /**
4
+ * A custom hook that returns an auth credential for facebook.
5
+ *
6
+ * @group Hook
7
+ * @param {AuthProvider} provider alas of a provider
8
+ *
9
+ * @returns {AuthCredential}
10
+ *
11
+ * @example
12
+ * ```jsx
13
+ * export const MyComponent = () => {
14
+ * const getCredential = useAppleAuthProviderCredential();
15
+ * // ...
16
+ * getCredential({token, nonce: ''})
17
+ * };
18
+ * ```
19
+ */
20
+ export const useAppleAuthProviderCredential = () => {
21
+ return useCallback((credential) => {
22
+ const authProvider = new OAuthProvider("apple.com");
23
+ return authProvider.credential({ accessToken: credential.token, rawNonce: credential.nonce });
24
+ }, []);
25
+ };
@@ -0,0 +1,32 @@
1
+ import { AuthCredential, OAuthProvider } from "firebase/auth";
2
+ import { useCallback } from "react";
3
+
4
+ type Credential = {
5
+ token: string;
6
+ nonce: string;
7
+ };
8
+
9
+ /**
10
+ * A custom hook that returns an auth credential for facebook.
11
+ *
12
+ * @group Hook
13
+ * @param {AuthProvider} provider alas of a provider
14
+ *
15
+ * @returns {AuthCredential}
16
+ *
17
+ * @example
18
+ * ```jsx
19
+ * export const MyComponent = () => {
20
+ * const getCredential = useAppleAuthProviderCredential();
21
+ * // ...
22
+ * getCredential({token, nonce: ''})
23
+ * };
24
+ * ```
25
+ */
26
+
27
+ export const useAppleAuthProviderCredential = () => {
28
+ return useCallback((credential: Credential): AuthCredential => {
29
+ const authProvider = new OAuthProvider("apple.com");
30
+ return authProvider.credential({ accessToken: credential.token, rawNonce: credential.nonce });
31
+ }, []);
32
+ };
@@ -1,18 +0,0 @@
1
- type AuthProvider = "google" | "facebook" | "email" | "github" | "twitter";
2
- /**
3
- * A custom hook that returns an auth provider by id.
4
- *
5
- * @group Hook
6
- * @param {AuthProvider} provider alas of a provider
7
- *
8
- * @returns {AuthProvider}
9
- *
10
- * @example
11
- * ```jsx
12
- * export const MyComponent = () => {
13
- * const authProvider = useAuthProvider('email');
14
- * };
15
- * ```
16
- */
17
- export declare const useAuthProvider: (provider: AuthProvider) => any;
18
- export {};
@@ -1,35 +0,0 @@
1
- import { EmailAuthProvider, FacebookAuthProvider, GithubAuthProvider, GoogleAuthProvider, TwitterAuthProvider } from "@react-native-firebase/auth";
2
- import { useMemo } from "react";
3
- /**
4
- * A custom hook that returns an auth provider by id.
5
- *
6
- * @group Hook
7
- * @param {AuthProvider} provider alas of a provider
8
- *
9
- * @returns {AuthProvider}
10
- *
11
- * @example
12
- * ```jsx
13
- * export const MyComponent = () => {
14
- * const authProvider = useAuthProvider('email');
15
- * };
16
- * ```
17
- */
18
- export const useAuthProvider = (provider) => {
19
- return useMemo(() => {
20
- switch (provider) {
21
- case "google":
22
- return new GoogleAuthProvider();
23
- case "email":
24
- return new EmailAuthProvider();
25
- case "facebook":
26
- return new FacebookAuthProvider();
27
- case "github":
28
- return new GithubAuthProvider();
29
- case "twitter":
30
- return new TwitterAuthProvider();
31
- default:
32
- throw new Error(`Auth provider ${provider} is not supported.`);
33
- }
34
- }, [provider]);
35
- };
@@ -1,45 +0,0 @@
1
- import {
2
- EmailAuthProvider,
3
- FacebookAuthProvider,
4
- GithubAuthProvider,
5
- GoogleAuthProvider,
6
- TwitterAuthProvider
7
- } from "@react-native-firebase/auth";
8
- import { useMemo } from "react";
9
-
10
- type AuthProvider = "google" | "facebook" | "email" | "github" | "twitter";
11
-
12
- /**
13
- * A custom hook that returns an auth provider by id.
14
- *
15
- * @group Hook
16
- * @param {AuthProvider} provider alas of a provider
17
- *
18
- * @returns {AuthProvider}
19
- *
20
- * @example
21
- * ```jsx
22
- * export const MyComponent = () => {
23
- * const authProvider = useAuthProvider('email');
24
- * };
25
- * ```
26
- */
27
-
28
- export const useAuthProvider = (provider: AuthProvider) => {
29
- return useMemo(() => {
30
- switch (provider) {
31
- case "google":
32
- return new GoogleAuthProvider();
33
- case "email":
34
- return new EmailAuthProvider();
35
- case "facebook":
36
- return new FacebookAuthProvider();
37
- case "github":
38
- return new GithubAuthProvider();
39
- case "twitter":
40
- return new TwitterAuthProvider();
41
- default:
42
- throw new Error(`Auth provider ${provider} is not supported.`);
43
- }
44
- }, [provider]);
45
- };