
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@custom-react-hooks/use-geo-location
Advanced tools
The `useGeoLocation` hook is a powerful tool for accessing and monitoring the user's geographical location in React applications. It offers features such as continuous location watching, error handling, and customizable geolocation options.
The useGeoLocation hook is a powerful tool for accessing and monitoring the user's geographical location in React applications. It offers features such as continuous location watching, error handling, and customizable geolocation options.
npm install @custom-react-hooks/use-geo-location
or
yarn add @custom-react-hooks/use-geo-location
npm install @custom-react-hooks/all
or
yarn add @custom-react-hooks/all
The useGeoLocation hook must be imported using a named import as shown below:
Named Import:
import { useGeoLocation } from '@custom-react-hooks/use-geo-location';
This approach ensures that the hook integrates seamlessly into your project, maintaining consistency and predictability in how you use our package.
Import and use the useGeoLocation hook in your React components:
import { useGeoLocation } from '@custom-react-hooks/all';
function GeoLocationComponent() {
const { loading, coordinates, error, isWatching } = useGeoLocation();
return (
<div>
<h1>GeoLocation Component</h1>
{loading && <p>Loading...</p>}
{!loading && error && <p>Error: {error.message}</p>}
{!loading && !error && coordinates && (
<div>
<p>Latitude: {coordinates.latitude}</p>
<p>Longitude: {coordinates.longitude}</p>
</div>
)}
<p>Watching: {isWatching ? 'Yes' : 'No'}</p>
</div>
);
}
export default GeoLocationComponent;
options: Optional PositionOptions object to configure geolocation queries.watch: Boolean flag to continuously watch the user's location.coordinates: The current geographical position of the user.error: Error object containing details in case of a failure.loading: Boolean indicating whether the location data is being fetched.Contributions to improve useGeoLocation are welcome. Feel free to submit issues or pull requests to enhance its functionality.
FAQs
The `useGeoLocation` hook is a powerful tool for accessing and monitoring the user's geographical location in React applications. It offers features such as continuous location watching, error handling, and customizable geolocation options.
We found that @custom-react-hooks/use-geo-location demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.