Size
0.38 kb
useGeolocation
Access and watch the browser's geolocation data.
Installation
Usage
When mounted, this hook begins tracking the user's location.
If location permissions haven't been granted yet, the browser will request permission from the user.
API Reference
UseGeolocationOptions
Options for the useGeolocation
hook. See MDN docs for more details.
Prop | Type | Default |
---|---|---|
maximumAge? | number | - |
timeout? | number | - |
enableHighAccuracy? | boolean | - |
UseGeolocationReturn
The return value of the useGeolocation
hook.
Prop | Type | Default |
---|---|---|
coords | GeolocationCoordinates & { timestamp: number | null } | - |
error | GeolocationPositionError | null | - |
state | "loading" | "watching" | "error" | - |