You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🌴Looking for a web/mobile developer? I'm actively seeking my next opportunity. Feel free to message me on LinkedIn! https://www.linkedin.com/in/lovesworking/
-**Continuous Evolution**: Built with expansion in mind, expect regular feature updates driven by community feedback and the evolving needs of modern development workflows.
14
38
-**Enhanced Manipulation**: Future updates will introduce capabilities for precise state adjustments, such as directly inserting complete objects or arrays, object duplication, simultaneous state syncing across web, Android, and iOS and persistent state overrides, allowing values for specific data to remain until manually reverted.
15
39
16
-
## Getting Started
40
+
## Prerequisites
17
41
18
-
### Prerequisites
42
+
### Client Application
19
43
20
-
#### Client Application:
21
44
- React version 18 or above.
22
45
- React Query version 5.17.19 or above.
23
46
24
-
#### Socket IO Server:
47
+
### Socket IO Server
48
+
25
49
- Socket.io version 4.7.4 or above.
26
50
27
-
### Installation
51
+
### Devtool Website
52
+
53
+
- Any react.js ready server (vite, rca, ...)
28
54
29
-
Install the package using npm by running the following command in your client project directory:
55
+
## Installation
56
+
57
+
### Client
58
+
59
+
#### 1. Install the package
30
60
31
61
```bash
32
62
npm install react-query-external-sync
33
63
```
34
64
35
-
## Usage
65
+
#### 2. Connect your react-query to the socket
66
+
36
67
- Import the useAllQueries hook and utilize it within your client application to enable real-time synchronization with the external dashboard.
-**query**: Contains user information for identifying and managing connections in the dashboard.
53
85
-**queryClient**: Your application's React Query client instance.
54
86
-**socketURL**: The URL where your Socket.io server is hosted.
55
87
56
-
### Connecting to the Server
57
-
58
-
Utilize the connect function to initiate a connection with the socket server. Monitor the connection status using isConnected.
59
-
60
-
### Disconnecting from the Server
61
-
62
-
Terminate the connection to the socket server by invoking the disconnect function.
63
-
64
-
### Accessing Queries
88
+
#### 3. Usages
65
89
66
-
The queries property grants access to the synchronized query data, facilitating debugging and state management.
90
+
-`.connect()`: initiate a connection with the socket server
91
+
-`.disconnect()`: terminate the connection to the socket server by invoking the disconnect function
92
+
-`.isConnected`: monitor the connection status
67
93
68
94
### Socket IO Server
69
95
70
-
Run the following command in your Node server directory:
96
+
#### 1. Install the package
71
97
72
98
```bash
73
99
npm install react-query-external-dash
74
100
```
75
101
76
-
##Socket IO Setup:
102
+
#### 2. Setup Socket IO
77
103
78
-
- After setting up your Socket.io server, integrate the socketHandle function to manage incoming and outgoing messages related to query state synchronization.
104
+
- After setting up your Socket.io server, integrate the socketHandle function to manage incoming and outgoing messages related to query state synchronization.
If you don't want to setup both Socket.IO + Dedicated React.js server to monitor your app, a Docker image is available to launch those both services at once, with custom ports and CORS urls.
110
155
111
-
##React Query Dev Tools Integration:
156
+
### 1. Image link
112
157
113
-
- Incorporate the ExternalDevTools component within your server-side dashboard to display and interact with the synchronized React Query states.
-`DT_PORT`: Port for the Vite server to access your devtool
164
+
-`CORS_ORIGINS`: String to specify authorized url's for CORS in form of: "url1,url2,url3,..." (separate with coma without spaces). **Note that the devtool url is automaticly included in the CORS Policy.**
165
+
166
+
### 3. Docker Compose example
117
167
118
-
<ExternalDevTools
119
-
query={{
120
-
clientType:"server",
121
-
username:"Admin",
122
-
userType:"admin",
123
-
}}
124
-
socketURL="http://localhost:4000"// Use local ip if testing localy for Android ie http://192.168.4.21:4000
125
-
/>
168
+
- You'll also need to open both ports to use this image. We suggest to define those in environment variables.
I welcome contributions, feedback, and bug reports. Feel free to open an issue or pull request on this GitHub repository.
186
+
187
+
<br>
188
+
<hr>
189
+
<br>
190
+
191
+
🌴Looking for a web/mobile developer? I'm actively seeking my next opportunity. Feel free to message me on LinkedIn! https://www.linkedin.com/in/lovesworking/
0 commit comments