fn
useGeolocation
v0.0.15testeddemoReactive 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
| Parameter | Type | Description |
|---|---|---|
options? | UseGeolocationOptions | Options |
Returns
UseGeolocationReturnReactive position, error, readiness, and watch controls