R
fn

useGeolocation

v0.0.15testeddemo

Reactive Geolocation API. Watches the device position, exposing reactive coordinates, error, and readiness state, plus pause/resume controls and a one-shot `getCurrentPosition`.

Examples

ts
const { coords, locatedAt, error, ready } = useGeolocation();
ts
// One-shot fetch without a continuous watch
const { getCurrentPosition } = useGeolocation({ immediate: false });
const position = await getCurrentPosition();

Demo

Loading demo…

Signature

ts
export function useGeolocation(options: UseGeolocationOptions ={ ... }

Parameters

ParameterTypeDescription
options?UseGeolocationOptionsOptions

Returns

UseGeolocationReturnReactive position, error, readiness, and watch controls