Skip to content

useGeolocation ​

browser
test coverage
Last changed: 28 days ago

TIP

This hook uses navigator.geolocation browser api to provide enhanced functionality. Make sure to check for compatibility with different browsers when using this api

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

Source ​

Source • Demo

Contributors ​

Avatardebabin
Avatarzeroqs

Released under the MIT License.