Skip to content

useGeolocation ​

Category
Browser

Hook that returns the current geolocation

typescript
import { useGeolocation } from '@siberiacancode/reactuse';

Usage ​

typescript
const { loading, error, timestamp, accuracy, latitude, longitude, altitude, altitudeAccuracy, heading, speed } = useGeolocation();

Demo ​

Api ​

Parameters

NameTypeDefaultNote
params.enableHighAccuracy?boolean-Enable high accuracy
params.maximumAge?number-Maximum age
params.timeout?number-Timeout

Contributors ​

Source • Demo