Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: react-query-firebase -> tanstack-query-firebase #115

Merged
merged 171 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
4910359
chore: Reset repository
Ehesp Sep 11, 2024
7ebf59b
refactor: setup next respository
Ehesp Sep 11, 2024
89f5edf
fix(tests): explicitly configure vitest to resolve ~/testing-util alias
HassanBahati Sep 14, 2024
7af518f
tests(useFirestoreDocument): add test for fetching doc from server so…
HassanBahati Sep 15, 2024
fb2da95
test(useFirestoreDocument): add test for handling fetch errors
HassanBahati Sep 15, 2024
2534174
test(useFirestoreDocument): add test for returning pending state init…
HassanBahati Sep 15, 2024
155c73f
test(useFirestoreDocument): add test to check if the correct data typ…
HassanBahati Sep 15, 2024
4f6e660
chore: fix typo
HassanBahati Sep 15, 2024
7742e0a
Merge pull request #100 from HassanBahati/fix-vitest-aliases
Ehesp Sep 18, 2024
40ecf5c
Merge branch 'next' into add-usefirestoredocument-tests
HassanBahati Sep 22, 2024
ee13917
tests(firestore): add expectFirestoreError to handle firestore errror…
HassanBahati Sep 24, 2024
239d829
tests(firestore): add expectFireError assertion utility to handle fir…
HassanBahati Sep 24, 2024
ba9babb
chore(firestore): rename useFirestoreDocument => useDocumentQuery
HassanBahati Sep 24, 2024
842c5ab
feat: Add useSignInAnonymouslyMutation hook
Ehesp Sep 24, 2024
8ffcbb4
Merge branch 'next' of https://github.com/invertase/react-query-fireb…
Ehesp Sep 24, 2024
74d675d
feat: Enable code-splitting bundling
Ehesp Sep 24, 2024
0c26c49
Merge pull request #101 from HassanBahati/add-usefirestoredocument-tests
Ehesp Sep 24, 2024
203750a
chore: Stub out wip function names
Ehesp Sep 24, 2024
d8be81f
tests(auth): add tests for useSignInAnonymouslyMutation
HassanBahati Sep 25, 2024
fc95e6e
tests(auth); test useSignInAnonymouslyMutation with emulator
HassanBahati Sep 26, 2024
0a80198
test(auth): test useSignInAnonymouslyMutation for multiple sequential…
HassanBahati Sep 26, 2024
10b72fc
feat(firestore): add useCollectionQuery
HassanBahati Sep 26, 2024
9b19f2a
feat(firestore): add useGetCountFromServerQuery hook
HassanBahati Sep 26, 2024
ec2ea93
feat(firestore): add useGetAggregateFromServerQuery hook
HassanBahati Sep 26, 2024
0131398
feat(firestore): add useGetAggregateFromServerQuery hook
HassanBahati Sep 26, 2024
ef9dec7
Merge pull request #104 from HassanBahati/add-usecollections-query
Ehesp Sep 26, 2024
2e73cfa
Merge pull request #103 from HassanBahati/add-usesigninanonymouslymut…
Ehesp Sep 26, 2024
7cb635e
Merge branch 'next' into add-useGetAggregateFromServerQuery-hook
HassanBahati Sep 26, 2024
7cb200e
chore: Add test workflow
Ehesp Sep 26, 2024
3b0ea49
Merge branch 'next' of https://github.com/invertase/react-query-fireb…
Ehesp Sep 26, 2024
6760104
chore: Fix next test branch
Ehesp Sep 26, 2024
5e86a93
refactor(firestore): move useGetAggregateFromServerQuery aggregateFie…
HassanBahati Sep 26, 2024
2e4e7bb
chore: ci
Ehesp Sep 26, 2024
64346b7
chore: ci
Ehesp Sep 26, 2024
aa93ed3
fix: Infer types
Ehesp Sep 26, 2024
1a2243a
refactor(firestore): remove optional chaining from snapshot
HassanBahati Sep 26, 2024
0a50dcf
Merge branch 'next' into add-useGetCountFromServerQuery-hook
HassanBahati Sep 27, 2024
868b34b
Merge branch 'invertase:main' into add-useGetCountFromServerQuery-hook
HassanBahati Sep 29, 2024
f09546a
refactor(firestore): return snapshot for useGetCountFromServerQuery
HassanBahati Sep 29, 2024
a6a7dda
refactor(firestore): return snapshot for useGetCountFromServerQuery
HassanBahati Sep 29, 2024
543713b
Merge branch 'invertase:main' into add-useGetAggregateFromServerQuery…
HassanBahati Sep 29, 2024
35a83bf
refactor(firestore): return snapshot for useGetAggregateFromServerQuery
HassanBahati Sep 29, 2024
7ebf95b
feat(firestore): add useWriteBatchCommitMutation
HassanBahati Sep 30, 2024
35175eb
feat(firestore): add useWaitForPendingWritesQuery
HassanBahati Sep 30, 2024
bd03c6e
feat(firestore): add useRunTransactionMutation
HassanBahati Sep 30, 2024
83ddb48
feat(firestore): add useRunTransactionMutation
HassanBahati Sep 30, 2024
5a7ebaa
feat(firestore): add useDisableNetworkMutation
HassanBahati Sep 30, 2024
fbe49e1
feat(firestore): add useClearIndexedDbPersistenceMutation
HassanBahati Sep 30, 2024
90795ac
refactor(firestore): remove unnecessary promises being created in use…
HassanBahati Sep 30, 2024
84d67f4
Merge pull request #105 from HassanBahati/add-useGetCountFromServerQu…
Ehesp Sep 30, 2024
720d5b8
refactor(firestore): remove unnecessary promises being created in use…
HassanBahati Sep 30, 2024
9c719b2
Merge branch 'next' into add-useGetAggregateFromServerQuery-hook
Ehesp Sep 30, 2024
3786583
Merge pull request #106 from HassanBahati/add-useGetAggregateFromServ…
Ehesp Sep 30, 2024
33a7ae7
Merge pull request #113 from HassanBahati/ft-add-useClearIndexedDbPer…
Ehesp Sep 30, 2024
507880a
Merge pull request #110 from HassanBahati/ft-add-useRunTransactionMut…
Ehesp Sep 30, 2024
25bf594
refactor(useWriteBatchCommitMutation): enable passing the batch into …
HassanBahati Sep 30, 2024
8633089
Merge branch 'next' into ft-add-useWriteBatchCommitMutation
HassanBahati Sep 30, 2024
69cc8a9
chore: merge next branch
HassanBahati Sep 30, 2024
6a7ba5c
refactor(useWaitForPendingWritesQuery): change from using a mutateFn …
HassanBahati Oct 1, 2024
7560be0
Merge branch 'next' into ft-useWaitForPendingWritesQuery
HassanBahati Oct 1, 2024
eafde59
refactor(useWriteBatchCommitMutation): directly return promise at the…
HassanBahati Oct 1, 2024
b201c96
tests(react-useDisableNetworkMutation): test with getDocFromServer si…
HassanBahati Oct 1, 2024
c54215d
Merge pull request #109 from HassanBahati/ft-useWaitForPendingWritesQ…
Ehesp Oct 7, 2024
e96dde9
Merge pull request #111 from HassanBahati/ft-add-useDisableNetworkMut…
Ehesp Oct 7, 2024
4d1704c
Merge branch 'next' into ft-add-useWriteBatchCommitMutation
HassanBahati Oct 7, 2024
ae1bff3
ci: Add emulator suite action
Ehesp Oct 7, 2024
7d8cca2
feat(useSignInWithCredentialMutation): add useSignInWithCredentialMut…
HassanBahati Oct 8, 2024
52ee754
chore: add expectFirestoreError util
HassanBahati Oct 8, 2024
07df286
tests(useSignInWithCredentialMutation): add tests
HassanBahati Oct 8, 2024
aa69949
_
HassanBahati Oct 8, 2024
54e1824
docs: Update readme and docs
Ehesp Oct 8, 2024
7ebcfd9
docs: Add more docs
Ehesp Oct 8, 2024
10f3395
feat(useSendSignInLinkToEmailMutation): add useSendSignInLinkToEmailM…
HassanBahati Oct 9, 2024
064bcf1
refactor(useSendSignInLinkToEmailMutation): allow passing reactive va…
HassanBahati Oct 9, 2024
6309453
Merge pull request #116 from HassanBahati/ft-add-useSendSignInLinkToE…
Ehesp Oct 10, 2024
8a9daa1
Merge pull request #108 from HassanBahati/ft-add-useWriteBatchCommitM…
Ehesp Oct 10, 2024
e2ef7e4
refactor: enhance error handling and logging for non-Firebase errors …
HassanBahati Oct 28, 2024
fd4b470
feat(useSignInWithEmailAndPasswordMutation): add useSignInWithEmailAn…
HassanBahati Nov 3, 2024
4fdf9b0
feat(useSignOutMutation): add useSignOutMutation hook
HassanBahati Nov 3, 2024
b6a755d
feat(useUpdateCurrentUserMutation): add useUpdateCurrentUserMutation …
HassanBahati Nov 3, 2024
4e0470e
refactor(useSignInWithEmailAndPasswordMutation): pass args directly i…
HassanBahati Nov 4, 2024
b2ae4ad
refactor(useUpdateCurrentUserMutation): pass args directly into the m…
HassanBahati Nov 4, 2024
51ede00
feat(useVerifyPasswordResetCodeMutation): add useVerifyPasswordResetC…
HassanBahati Nov 9, 2024
9c4d36f
feat(useDeleteUserMutation): add useDeleteUserMutation hook
HassanBahati Nov 9, 2024
59c982f
feat(useReloadMutation): add useReloadMutation hook
HassanBahati Nov 10, 2024
c952f00
chore: upgrade firebase to ^11.0.2
HassanBahati Nov 25, 2024
4dc0694
feat: initialize dataconnect
HassanBahati Nov 25, 2024
ec93489
feat; add useConnectQuery
HassanBahati Nov 25, 2024
afc37ab
_
HassanBahati Nov 25, 2024
2423396
chore: ignore firebase cache
HassanBahati Nov 25, 2024
42d1f78
chore: register dataconnect paths
HassanBahati Nov 25, 2024
2aa2bab
feat: setup dataconnect
HassanBahati Nov 25, 2024
64b8ca2
chore: rename app => firebaseApp
HassanBahati Nov 25, 2024
02a429a
tests(useConnectQuery): initialize firebase app
HassanBahati Nov 25, 2024
0dd6642
_
HassanBahati Nov 25, 2024
fc83176
test(useConnectQuery): test for successful data retrieval
HassanBahati Nov 26, 2024
ca32ab8
chore: add query client utils
HassanBahati Nov 26, 2024
1a97407
_
HassanBahati Nov 26, 2024
43cf421
chore: export data-connect hooks
HassanBahati Nov 26, 2024
8a4ea32
test(useConnectQuery): add tests
HassanBahati Nov 26, 2024
a174a92
feat(useConnectMutation): add useConnectMutation hook
HassanBahati Nov 27, 2024
18f9039
chore: ignore firebase cache
HassanBahati Nov 27, 2024
3a423d0
docs: add dataconnect tab group
HassanBahati Nov 27, 2024
24f4731
fix: group dataconnect hooks in same category
HassanBahati Nov 27, 2024
3af36ba
docs(useConnectQuery): add useConnectQuery docs
HassanBahati Nov 27, 2024
3430502
docs: fix route path
HassanBahati Nov 27, 2024
4fbfe14
docs: fix typo
HassanBahati Nov 27, 2024
b6c00e8
docs(useConnectMutation): add useConnectMutation docs
HassanBahati Nov 27, 2024
91a7e9f
chore: export useConnectMutation
HassanBahati Nov 27, 2024
bf71d3c
chore: ignore firebase cache
HassanBahati Dec 1, 2024
ffc8cf0
tests: disable file parallelism to solve race conditions
HassanBahati Dec 1, 2024
9162d7a
chore: upgrade firebase-emulator-action to v1.0.1
HassanBahati Dec 1, 2024
2e52626
chore: Upgrade invertase/firebase-emulator-action to v1.0.1
HassanBahati Dec 1, 2024
def47f0
fix: remove unknown annotation
HassanBahati Dec 1, 2024
abc50bb
chore: rename FirestoreUseMutationOptions=> FirestoreUseMutationOptions
HassanBahati Dec 1, 2024
898cb14
ci(tests): verify running emulators
HassanBahati Dec 1, 2024
800322e
docs(dataconnect): import hooks from @tanstack-query-firebase/react
HassanBahati Dec 2, 2024
f280b10
docs(useConnectMutation): add example hook usage
HassanBahati Dec 2, 2024
436006d
docs(dataconnect): remove leading slash when importing from scoped pa…
HassanBahati Dec 2, 2024
2f4e6ed
docs(dataconnect): fix typos
HassanBahati Dec 2, 2024
13f336a
Merge pull request #114 from HassanBahati/ft-add-useSignInWithCredent…
Ehesp Dec 4, 2024
8c4dec1
Merge pull request #127 from HassanBahati/ft-add-useReloadMutation
Ehesp Dec 4, 2024
a5a8d2b
Merge pull request #125 from HassanBahati/ft-add-useDeleteUserMutation
Ehesp Dec 4, 2024
a21b53a
Merge pull request #122 from HassanBahati/ft-add-useUpdateCurrentUser…
Ehesp Dec 4, 2024
6bf741d
Merge pull request #120 from HassanBahati/ft-add-useSignInWithEmailAn…
Ehesp Dec 4, 2024
86e04a1
Merge pull request #124 from HassanBahati/ft-add-useVerifyPasswordRes…
Ehesp Dec 4, 2024
6f32041
Merge branch 'next' into ft-add-useSignOutMutation
Ehesp Dec 4, 2024
b424dd1
Merge pull request #121 from HassanBahati/ft-add-useSignOutMutation
Ehesp Dec 4, 2024
ce3d81c
Merge branch 'next' into ft-fix-tests
HassanBahati Dec 6, 2024
a1a3811
Merge branch 'next' into ft-add-useConnectQuery
HassanBahati Dec 6, 2024
068ba9e
chore(dataconnect): update sdk
HassanBahati Dec 7, 2024
d61f99b
feat(useConnectQuery): enable passing query options
HassanBahati Dec 7, 2024
d3ae0fc
feat(useConnectMutation): implement invalidate option
HassanBahati Dec 7, 2024
b25ac40
chore(useConnectQuery): add FirebaseError as default Error
HassanBahati Dec 7, 2024
6990076
chore: prefix default project name with demo-
HassanBahati Dec 15, 2024
4a6b315
fix: prefix @dataconnect/default-connector version with workspace:* t…
HassanBahati Dec 15, 2024
d7d3408
_
HassanBahati Dec 15, 2024
771da3c
feat(dataconnect): add upsert mutation
HassanBahati Dec 16, 2024
294cf5a
feat(dataconnect): add delete mutation
HassanBahati Dec 16, 2024
91e40c1
feat(dataconnect): add upsert and delete mutations
HassanBahati Dec 16, 2024
cfdf3da
test(useConnectMutation): add tests
HassanBahati Dec 16, 2024
aef9440
test(useConnectMutation): add tests
HassanBahati Dec 16, 2024
a33dcf7
fix: Allow queryKey to be optional
Ehesp Dec 16, 2024
2007da9
chore: add data-connect to exports map
HassanBahati Dec 16, 2024
1136e11
feat(dataconnect): add getMovieById query
HassanBahati Dec 16, 2024
e99b87f
test(useConnectQuery): add test for fetching data by unique identifier
HassanBahati Dec 16, 2024
e269caa
Merge pull request #129 from HassanBahati/ft-add-useConnectQuery
Ehesp Dec 16, 2024
73a0b64
Merge pull request #133 from HassanBahati/ft-fix-tests
Ehesp Dec 16, 2024
8c721c0
chore: Add React example
Ehesp Dec 17, 2024
1b02a00
feat: Support flattened result structure
Ehesp Dec 17, 2024
1d2fc5a
tests(useConnectQuery): test that the hook returns flattened data inc…
HassanBahati Dec 18, 2024
a626a21
test(useConnectQuery): test for when QueryResult is passed, the init…
HassanBahati Dec 18, 2024
f359e3c
test(useConnectQuery): test for when QueryResult is passed, the init…
HassanBahati Dec 18, 2024
2b6bce7
test(useConnectQuery): returns flattened data including ref, source, …
HassanBahati Dec 18, 2024
90355f1
test(useConnectQuery): a query with no variables has null as the seco…
HassanBahati Dec 19, 2024
fc05fef
test(useConnectQuery): a query with variables has valid query keys in…
HassanBahati Dec 19, 2024
242df90
Merge pull request #132 from HassanBahati/docs-useConnectQuery-useCon…
Ehesp Dec 20, 2024
0d72bef
docs: Update data connect docs
Ehesp Dec 20, 2024
bd467c5
refactor(useConnectMutation): update invalidate assertioins after mut…
HassanBahati Dec 20, 2024
94c32c1
fix(useConnectMutation): fix false positive when "variables" in ref i…
HassanBahati Dec 21, 2024
d860178
test(useConnectMutation); add tests
HassanBahati Dec 21, 2024
3ec1243
test(useConnectQuery): test for data refetching
HassanBahati Dec 21, 2024
b178072
fix(ci): update lockfile
HassanBahati Dec 21, 2024
5e4669f
Merge branch 'next' into additional-useConnectQuery-useConnectMutatio…
HassanBahati Dec 21, 2024
17a5876
ci: add step for starting dataconnect emulator
HassanBahati Dec 22, 2024
5474115
ci: add dataconnect to emulators options
HassanBahati Dec 22, 2024
440b862
_
HassanBahati Dec 22, 2024
d9df02c
ci: add dataconnect to emulators options
HassanBahati Dec 22, 2024
bb94a9c
Merge pull request #134 from HassanBahati/additional-useConnectQuery-…
Ehesp Dec 23, 2024
18304ee
docs: Add stub docs
Ehesp Dec 23, 2024
dcf569d
docs: Update docs
Ehesp Dec 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

50 changes: 0 additions & 50 deletions .eslintrc.json

This file was deleted.

8 changes: 7 additions & 1 deletion .firebaserc
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"projects": {
"default": "demo-project"
},
"targets": {},
"etags": {}
}
45 changes: 0 additions & 45 deletions .github/workflows/testing.yaml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Tests

on:
push:
branches:
- next
pull_request:
branches:
- next

jobs:
test:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false # We'll do this later

# Setup Node.js with pnpm
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

# Install all dependencies at the root
- name: Install dependencies (pnpm)
run: pnpm install

- name: Start Firebase Emulator Suite
uses: invertase/[email protected]
with:
emulators: 'auth,firestore,functions,storage,database,dataconnect'

- name: Verify Running Emulators
run: |
curl --silent http://localhost:4400/emulators | jq 'keys[]'

# Determine which packages have changed
- name: Determine changed packages
id: changes
uses: dorny/paths-filter@v2
with:
filters: |
react:
- 'packages/react/**'

# Run tests for the React package if it has changed
- name: Run React Tests
if: steps.changes.outputs.react == 'true'
run: pnpm vitest --dom 'packages/react'

# Run tests for the Vue package if it has changed
# - name: Run Vue Tests
# if: steps.changes.outputs.vue == 'true'
# run: pnpm --filter vue test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ dist

functions/lib/**/*.js
functions/lib/**/*.js.map

# Firebase cache
.firebase/
7 changes: 0 additions & 7 deletions .prettierignore

This file was deleted.

163 changes: 52 additions & 111 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,135 +1,76 @@
> [!IMPORTANT]
> This project is currently undergoing a overhaul, to support TanStack v5 - this includes a package restructuring, and enables support for other web frameworks!
> This project is currently a work in progress. Please check back soon for updates!

<h1 align="center">React Query Firebase</h1>
<h1 align="center">TanStack Query Firebase</h1>
<p align="center">
<span>A set of <a href="https://react-query.tanstack.com">React Query</a> hooks integrating with <a href="https://firebase.google.com/">Firebase</a>.</span>
<span>A set of <a href="https://tanstack.com/query/latest">TanStack Query</a> hooks integrating with <a href="https://firebase.google.com/">Firebase</a>.</span>
</p>
<p align="center">
<span><a href="#installation">Installation</a> &bull;
<a href="https://react-query-firebase.invertase.dev/"> Documentation</a> &bull;
<a href="https://invertase.docs.page/tanstack-query-firebase"> Documentation</a> &bull;
<a href="/LICENSE.md">License</a></span>
</p>
<br />

React Query Firebase provides a set of easy to use hooks for handling asynchronous tasks with Firebase in your React application.

## Why should I use React Query Firebase?

- **Backed by React Query** - Unlike other solutions, hooks are built on top of [React Query](https://react-query.tanstack.com) which takes care of complex challenges
such as caching, automatic refetching, realtime data subscriptions, pagination & infinite queries, mutations, SSR Support, data selectors, side effect handlers and more. You also get [DevTool](https://react-query.tanstack.com/devtools)
support out of the box!
- **Un-opinionated** - You provide the Query Keys, Configuration & Firebase instances, allowing for full control over how your data is integrated and cached. You can also roll it alongside any existing Firebase usage.
- **Performant & Efficient** - Whether your queries are one-off or realtime, the library is designed to be performant and efficient. Data fetching is handled via [Queries](https://react-query.tanstack.com/guides/queries) and
[Query Keys](https://react-query.tanstack.com/guides/query-keys), meaning components can share data throughout your application without needless database reads.
- **Mutations** - Sign a user in, delete a document, run a transaction, log an event... React Query Firebase takes care of that for you via [Mutations](https://react-query.tanstack.com/guides/mutations), allowing you to focus
on your application and not managing complex local loading & error states.
- **Fully Typed** - The library is built with and has full compatibility with TypeScript.

> **Note**: The library supports the Firebase JS SDK v9 - [learn more about it here](https://firebase.googleblog.com/2021/08/the-new-firebase-js-sdk-now-ga.html)!

## Example

As an example, let's use a Firestore hooks to fetch a document & run a transaction whilst easily handling asynchronous state.

```tsx
import {
useFirestoreDocument,
useFirestoreTransaction,
} from "@react-query-firebase/firestore";
import { doc } from "firebase/firestore";
import { firestore } from "./config/firebase";

type Product = {
name: string;
price: number;
};

function ProductPage({ id }: { id: string }) {
// Create a Firestore document reference
const ref = doc(firestore, "products", id);

// Query a Firestore document using useQuery
const product = useFirestoreDocument<Product>(
["product", id],
ref,
{
// Subscribe to realtime changes
subscribe: true,
// Include metadata changes in the updates
includeMetadataChanges: true,
},
{
// Optionally handle side effects with React Query hook options
onSuccess(snapshot) {
console.log("Successfully fetched product ID: ", snapshot.id);
},
}
);

// Run a Firestore transaction as Mutation using useMutation
const like = useFirestoreTransaction(
auth,
async (tsx) => {
const record = await tsx.get(ref);
tsx.update(ref, {
likes: record.data().likes + 1,
});
},
{
onError(error) {
console.error("Failed to like product!", error);
},
}
);

if (product.isLoading) {
return <div>Loading...</div>;
}

if (product.isError) {
return <div>Failed to fetch product: {product.error.message}</div>;
}

const snapshot = product.data; // DocumentSnapshot<Product>

return (
<div>
<h1>{snapshot.data().name}</h1>
<button disabled={like.isLoading} onClick={() => like.mutate()}>
Like Product!
</button>
{like.isError && <p>Failed to like product: {like.error.message}</p>}
</div>
);
}
```
TanStack Query Firebase provides a set of hooks for handling asynchronous tasks with Firebase in your applications.

## Installation
> Looking for React Query Firebase? Check out the [old branch](https://github.com/invertase/tanstack-query-firebase/tree/react-query-firebase).

If you haven't done so already, install `react`, `react-query` & `firebase` (v9):
## Why use this library?

```bash
npm i --save react react-query firebase
```
When managing Firebase’s asynchronous API calls within your application, state synchronization can become cumbersome in most applications. You will commonly find yourself handling loading states, error states, and data synchronization manually.

This library provides a hands-off approach to these problems, by leveraging the popular [TanStack Query](https://tanstack.com/query/latest) project. Out of the box, you get:

Before using this library, ensure React Query is setup on your project by following the [Installation](https://react-query.tanstack.com/quick-start) guide.
- **Automatic Caching**: Avoid redundant Firebase calls with built-in caching.
- **Out-of-the-box Synchronization**: TanStack Query keeps your UI in sync with the Firebase backend effortlessly.
- **Background Updates**: Fetch and sync data seamlessly in the background without interrupting the user experience.
- **Error Handling & Retries**: Get automatic retries on failed Firebase calls, with robust error handling baked in.
- **Dev Tools for Debugging**: Leverage the React Query Devtools to gain insights into your data-fetching logic and Firebase interactions.

Next install one of the React Query Firebase packages, e.g:
By combining Firebase with TanStack Query, you can make your app more resilient, performant, and scalable, all while writing less code.

## Installation

This project expects you have `firebase` installed as a peer dependency. If you haven't done so already, install `firebase`:

```bash
npm i --save @react-query-firebase/firestore
npm i --save firebase
```

See below for a full list of available packages.
Next, install specific packages for your framework of choice:

### React

## Packages
```
npm i --save @tanstack/react-query @tanstack-query-firebase/react
```

- [`@react-query-firebase/analytics`](https://react-query-firebase.invertase.dev/analytics)
- [`@react-query-firebase/auth`](https://react-query-firebase.invertase.dev/auth)
- [`@react-query-firebase/database`](https://react-query-firebase.invertase.dev/database)
- [`@react-query-firebase/firestore`](https://react-query-firebase.invertase.dev/firestore)
- [`@react-query-firebase/functions`](https://react-query-firebase.invertase.dev/functions)
See the [Documentation](https://invertase.docs.page/tanstack-query-firebase/react) for more information on how to use the library.

## Status

The status of the following Firebase services and frameworks are as follows:

- ✅ Ready for use
- 🟠 Work in progress
- () Not yet started

| Module | React | Vue | Solid | Angular | Svelte |
|----------------|--:-:--|--:-:--|--:-:--|--:-:----|--:-:---|
| analytics | | | | | |
| app-check | | | | | |
| auth | 🟠 | | | | |
| database | | | | | |
| data-connect | ✅ | | | | |
| firestore | 🟠 | | | | |
| firestore/lite | | | | | |
| functions | | | | | |
| installations | | | | | |
| messaging | | | | | |
| performance | | | | | |
| remote-config | | | | | |
| vertexai | | | | | |

## License

Expand Down
7 changes: 0 additions & 7 deletions babel.config.js

This file was deleted.

Loading
Loading