Headless GPS tracking action — watches device position and fires callbacks
GPSTracker is a headless component — it renders only a small status indicator and fires onLocationUpdate on each new fix. Your app decides what to do with the coordinates
(send to server, drive a LocationMap, update a field, etc.).
<GPSTracker
enabled={isOnShift}
updateInterval={30}
onLocationUpdate={async (pos) => {
await fetch('/api/location', {
method: 'POST',
body: JSON.stringify({
lat: pos.coords.latitude,
lng: pos.coords.longitude
})
});
}}
/>| Prop | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Start/stop tracking |
updateInterval | number | 30 | Polling interval in seconds (desktop fallback) |
onLocationUpdate | (pos: GeolocationPosition) => void | - | Called on each new position fix |
onError | (err: GeolocationPositionError) => void | - | Called when geolocation fails |