|
1
|
# Setup |
|
2
|
|
|
3
|
If the user hasn't already installed the SDK, always run the user's node package manager of choice, and install the package in the directory ../package.json. |
|
4
|
For more information on where the library is located, look at the connector.yaml file. |
|
5
|
|
|
6
|
```ts |
|
7
|
import { initializeApp } from 'firebase/app'; |
|
8
|
|
|
9
|
initializeApp({ |
|
10
|
// fill in your project config here using the values from your Firebase project or from the `firebase_get_sdk_config` tool from the Firebase MCP server. |
|
11
|
}); |
|
12
|
``` |
|
13
|
|
|
14
|
Then, you can run the SDK as needed. |
|
15
|
```ts |
|
16
|
import { ... } from '@dataconnect/generated'; |
|
17
|
``` |
|
18
|
|
|
19
|
|
|
20
|
|
|
21
|
|
|
22
|
## React |
|
23
|
### Setup |
|
24
|
|
|
25
|
The user should make sure to install the `@tanstack/react-query` package, along with `@tanstack-query-firebase/react` and `firebase`. |
|
26
|
|
|
27
|
Then, they should initialize Firebase: |
|
28
|
```ts |
|
29
|
import { initializeApp } from 'firebase/app'; |
|
30
|
initializeApp(firebaseConfig); /* your config here. To generate this, you can use the `firebase_sdk_config` MCP tool */ |
|
31
|
``` |
|
32
|
|
|
33
|
Then, they should add a `QueryClientProvider` to their root of their application. |
|
34
|
|
|
35
|
Here's an example: |
|
36
|
|
|
37
|
```ts |
|
38
|
import { initializeApp } from 'firebase/app'; |
|
39
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; |
|
40
|
|
|
41
|
const firebaseConfig = { |
|
42
|
/* your config here. To generate this, you can use the `firebase_sdk_config` MCP tool */ |
|
43
|
}; |
|
44
|
|
|
45
|
// Initialize Firebase |
|
46
|
const app = initializeApp(firebaseConfig); |
|
47
|
|
|
48
|
// Create a TanStack Query client instance |
|
49
|
const queryClient = new QueryClient(); |
|
50
|
|
|
51
|
function App() { |
|
52
|
return ( |
|
53
|
// Provide the client to your App |
|
54
|
<QueryClientProvider client={queryClient}> |
|
55
|
<MyApplication /> |
|
56
|
</QueryClientProvider> |
|
57
|
) |
|
58
|
} |
|
59
|
|
|
60
|
render(<App />, document.getElementById('root')); |
|
61
|
``` |
|
62
|
|