{"repo":"no23reason/react-geolocated","free":true,"listed":false,"github":"https://github.com/no23reason/react-geolocated","clone":"git clone https://github.com/no23reason/react-geolocated.git","description":"React hook for using Geolocation API","language":"TypeScript","stars":328,"topics":["geolocation-api","react","gps","geolocation","hooks","react-hook","react-hooks","typescript"],"license":"MIT","category":"ui-components","readme_excerpt":"react-geolocated - React hook for using Geolocation API Demo Basic demo can be found at the demo page. HOC version This package used to be a HOC, not a hook. If you want to use the HOC version, please stick with versions < 4. Basic Usage Install using npm : Then use in your application like this: Hook return value The values returned from the hook are: The coords value is equivalent to the Coordinates object and the positionError is equivalent to the PositionError. Configuration The useGeolocated hook takes optional configuration parameter: The positionOptions object corresponds to the PositionOptions of the Geolocation API. By default the hook only sets position once. To watch the user's position and provide live updates to position, set watchPosition = true . The geolocation event handler is unregistered when the hook unmounts. If set, the userDecisionTimeout determines how much time (in milliseconds) we give the user to make the decision whether to allow to share their location or not. In Firefox, if the user declines to use their location, the Geolocation API call does not end with an error. Therefore we want to fallback to the error state if the user declines and the API does not tell us. The location is obtained when the hook mounts by default. If you want to prevent this and get the location later, set the suppressLocationOnMount to true and use the getPosition function returned by the hook to trigger the geolocation query manually. The geolocationProvider allows to sp","default_branch":null,"files":null,"tree":[],"storefront":"/r/no23reason","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/no23reason/react-geolocated/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}