jatui

GPSTracker

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.).

Live demo

Typical usage

<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
      })
    });
  }}
/>

Props

PropTypeDefaultDescription
enabledbooleantrueStart/stop tracking
updateIntervalnumber30Polling interval in seconds (desktop fallback)
onLocationUpdate(pos: GeolocationPosition) => void-Called on each new position fix
onError(err: GeolocationPositionError) => void-Called when geolocation fails