useSimData. The lower-level hooks (useSocket, useSimulatorData, etc.) are available when you need direct event access.
Import
useSimData
TanStack Query + Socket.io hook for real-time simulator data. Hydrates from GET /api/simulator/snapshot on mount, then subscribes to simulator:data and simulator:status events via Socket.io.
Performance: Simulator data arrives at 10–20 Hz. Updates are buffered and flushed via requestAnimationFrame, aligning cache writes to the browser’s ~60 fps paint cycle. Multiple components share a single TanStack Query cache entry — there is no duplicate subscription overhead.
Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
options.select | (snapshot: SimDataSnapshot) => TSelected | Selector function. The component only re-renders when the selected value changes. |
SimDataSnapshot
FlightData contains all simulator variables: position, speed, altitude, heading, engine data, fuel, weather, flaps, gear, and more. Import the type from @skyvexsoftware/stratos-sdk for the full definition.
Usage
useSocket
Core Socket.io connection hook. Uses a singleton SocketManager — all consumers share a single underlying socket. The socket connects when the first subscriber mounts and disconnects one second after the last subscriber unmounts.
Signature
Usage
useSimulatorData
Raw event streaming hook. Calls your callbacks directly on each simulator:data and simulator:status event. Prefer useSimData unless you need the raw payload or must bypass TanStack Query caching.
Signature
Usage
useProtocolUrl
Receives deep link events dispatched when the OS opens a stratos:// URL while the app is running.