1.0.6 ā€¢ Published 2 months ago

geo-location-hook v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

GeolocateMe

A ReactJS hook to get the geo-location of the users.

šŸ«¶ Support

Liked it? You can show your support with a STAR(ā­).

šŸ”§ Features: 1. Retrieves the user's current coordinates (latitude and longitude) using the Geolocation API. 2. Handles cases where geolocation is not supported or the user denies permission. 3. Returns a state object with loading status , coordinates and error, making it easy to manage location data in your components.

How to use it?

You can use the project in this way:

Install

# with npm
npm install geo-location-hook

# with yarn
yarn add geo-location-hook

Usage

import React from 'react';
import {useGeoLocation} from 'geo-location-hook';

const MyComponent = () => {
  const { loading, coordinates, error } = useGeoLocation();

  if (!loading) {
    return <div>Loading...</div>;
  }

  if (error) {
    return <div>Error: {error.message}</div>;
  }

  return (
    <div>
      Latitude: {coordinates.latitude}, Longitude: {coordinates.longitude}
    </div>
  );
};

export default MyComponent;
1.0.6

2 months ago

1.0.5

2 months ago

1.0.4

2 months ago

1.0.3

2 months ago

1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago