Gathering detailed insights and metrics for react-native-devtools-sync
Gathering detailed insights and metrics for react-native-devtools-sync
Gathering detailed insights and metrics for react-native-devtools-sync
Gathering detailed insights and metrics for react-native-devtools-sync
A tool that can be used by anyone to manage React Query state externally.
npm install react-native-devtools-sync
Typescript
Module System
Node Version
NPM Version
69.2
Supply Chain
97.2
Quality
82.5
Maintenance
100
Vulnerability
100
License
TypeScript (99.63%)
JavaScript (0.37%)
Total Downloads
202
Last Day
9
Last Week
33
Last Month
202
Last Year
202
MIT License
52 Commits
1 Branches
1 Contributors
Updated on May 14, 2025
Minified
Minified + Gzipped
Latest Version
2.0.3
Package Id
react-native-devtools-sync@2.0.3
Unpacked Size
171.07 kB
Size
32.26 kB
File Count
41
NPM Version
10.8.2
Node Version
20.18.3
Published on
May 14, 2025
Cumulative downloads
Total Downloads
3
A powerful debugging tool for React Query state in any React-based application. Whether you're building for mobile, web, desktop, TV, or VR - this package has you covered. It works seamlessly across all platforms where React runs, with zero configuration to disable in production.
Pairs perfectly with React Native DevTools for a complete development experience.
1# Using npm 2npm install --save-dev react-native-devtools-sync socket.io-client 3 4# Using yarn 5yarn add -D react-native-devtools-sync socket.io-client 6 7# Using pnpm 8pnpm add -D react-native-devtools-sync socket.io-client
Add the hook to your application where you set up your React Query context:
1import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; 2import { useSyncQueriesExternal } from "react-query-external-sync"; 3// Import Platform for React Native or use other platform detection for web/desktop 4import { Platform } from "react-native"; 5 6// Create your query client 7const queryClient = new QueryClient(); 8 9function App() { 10 return ( 11 <QueryClientProvider client={queryClient}> 12 <AppContent /> 13 </QueryClientProvider> 14 ); 15} 16 17function AppContent() { 18 // Set up the sync hook - automatically disabled in production! 19 useSyncQueriesExternal({ 20 queryClient, 21 socketURL: "http://localhost:42831", // Default port for React Native DevTools 22 deviceName: Platform?.OS || "web", // Platform detection 23 platform: Platform?.OS || "web", // Use appropriate platform identifier 24 deviceId: Platform?.OS || "web", // Use a PERSISTENT identifier (see note below) 25 extraDeviceInfo: { 26 // Optional additional info about your device 27 appVersion: "1.0.0", 28 // Add any relevant platform info 29 }, 30 enableLogs: false, 31 // Enable AsyncStorage monitoring (optional) 32 asyncStorage: AsyncStorage, 33 // Enable network monitoring (optional) 34 networkMonitoring: { 35 fetch: true, 36 xhr: true, 37 websocket: false 38 }, 39 // Enable Expo DevTools (optional) 40 expoDevTools: { 41 enabled: true 42 } 43 }); 44 45 // Your app content 46 return <YourApp />; 47}
This package is automatically disabled in production builds.
1// The package handles this internally: 2if (process.env.NODE_ENV !== "production") { 3 useSyncQueries = require("./new-sync/useSyncQueries").useSyncQueries; 4} else { 5 // In production, this becomes a no-op function 6 useSyncQueries = () => ({ 7 isConnected: false, 8 connect: () => {}, 9 disconnect: () => {}, 10 socket: null, 11 users: [], 12 }); 13}
For the best experience, use this package with the React Native DevTools application:
Note: For optimal connection, launch DevTools before starting your application.
This package now includes Remote Expo DevTools, allowing you to trigger Expo DevTools commands remotely without using the command line.
1useSyncQueriesExternal({ 2 // ... other options 3 expoDevTools: { 4 enabled: true 5 } 6});
1import { useSyncQueriesExternal } from "react-query-external-sync"; 2 3// Simply enable Expo DevTools - no implementation needed! 4useSyncQueriesExternal({ 5 // ... other options 6 expoDevTools: { 7 enabled: true 8 } 9});
The library now includes default implementations for all Expo commands that will automatically detect and use the appropriate APIs based on your environment. These implementations will:
If you need custom behavior, you can still override any command:
1import { 2 setExpoCommandImplementations, 3 useSyncQueriesExternal 4} from "react-query-external-sync"; 5 6// Override only the commands you need custom behavior for 7setExpoCommandImplementations({ 8 reload: async () => { 9 console.log("Custom reload implementation"); 10 // Your custom implementation 11 await YourCustomReloadFunction(); 12 }, 13 // You can override just one or a few commands 14 // Other commands will use the default implementations 15});
reload
: Reload the apptoggle-inspector
: Toggle the element inspectortoggle-performance-monitor
: Toggle the performance monitortoggle-element-inspector
: Toggle the element inspectorclear-cache
: Clear the app cachetoggle-remote-debugging
: Toggle remote debuggingopen-dev-menu
: Open the developer menutake-screenshot
: Take a screenshotshake-device
: Simulate device shakeThe useSyncQueriesExternal
hook accepts the following options:
Option | Type | Required | Description |
---|---|---|---|
queryClient | QueryClient | Yes | Your React Query client instance |
socketURL | string | Yes | URL of the socket server (e.g., 'http://localhost:42831') |
deviceName | string | Yes | Human-readable name for your device |
platform | string | Yes | Platform identifier ('ios', 'android', 'web', 'macos', 'windows', etc.) |
deviceId | string | Yes | Unique identifier for your device |
extraDeviceInfo | object | No | Additional device metadata to display in DevTools |
enableLogs | boolean | No | Enable console logging for debugging (default: false) |
asyncStorage | AsyncStorage | No | AsyncStorage implementation for monitoring |
networkMonitoring | NetworkMonitoringOptions | No | Configure network request monitoring |
expoDevTools | ExpoDevToolsOptions | No | Configure Expo DevTools integration |
DevTools Connection
No Devices Appearing
npm list socket.io-client
)socketURL
matches the DevTools port (default: 42831)Data Not Syncing
queryClient
instanceenableLogs: true
to see connection informationThat's it! If you're still having issues, visit the GitHub repository for support.
The deviceId
parameter must be persistent across app restarts and re-renders. Using a value that changes (like Date.now()
) will cause each render to be treated as a new device.
Recommended approaches:
1// Simple approach for single devices
2deviceId: Platform.OS, // Works if you only have one device per platform
3
4// Better approach for multiple simulators/devices of same type
5// Using AsyncStorage, MMKV, or another storage solution
6const [deviceId, setDeviceId] = useState(Platform.OS);
7
8useEffect(() => {
9 const loadOrCreateDeviceId = async () => {
10 // Try to load existing ID
11 const storedId = await AsyncStorage.getItem('deviceId');
12
13 if (storedId) {
14 setDeviceId(storedId);
15 } else {
16 // First launch - generate and store a persistent ID
17 const newId = `${Platform.OS}-${Date.now()}`;
18 await AsyncStorage.setItem('deviceId', newId);
19 setDeviceId(newId);
20 }
21 };
22
23 loadOrCreateDeviceId();
24}, []);
This project is a fork with added features. A huge thank you to LovesWorking for creating the original React Query External Sync package, which provided an excellent foundation for this enhanced version. Your work has been instrumental in making React Query debugging easier and more powerful.
MIT
Original package by LovesWorking
Enhanced with Remote Expo DevTools functionality
No vulnerabilities found.
No security vulnerabilities found.
Last Day
800%
9
Compared to previous day
Last Week
57.1%
33
Compared to previous week
Last Month
0%
202
Compared to previous month
Last Year
0%
202
Compared to previous year