JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q39779F
  • License ISC

usegeoaddress is a lightweight npm package that retrieves users' current location, including city, district, and region details. It also handles location permission errors seamlessly for a smooth user experience.

Package Exports

  • usegeoaddress
  • usegeoaddress/usegeoaddress.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (usegeoaddress) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

usegeoaddress Hook

Description

The usegeoaddress hook is a custom hook that allows retrieving the user's geolocation address using the browser's Geolocation API. This hook simplifies the process of fetching and managing the address information associated with a given latitude and longitude.

Installation

To install the usegeoaddress hook, follow these steps:

Make sure you have React installed in your project.

$ npm install react

Install the usegeoaddress hook using npm or yarn.
   $ npm install usegeoaddress
   $ yarn add usegeoaddress

Usage

Here's an example of how to use the usegeoaddress hook in a React file:

import React from "react";
import usegeoaddress from "usegeoaddress";

function App() {
  const { address, err, status } = usegeoaddress();

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

  if (status !== "granted") {
    return <div>Permission to access location was denied</div>;
  }

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

  return (
    <div>
      <h1>Address Details</h1>
      <p>Street: {address.street}</p>
      <p>City: {address.city}</p>
      <p>State: {address.state}</p>
      <p>Country: {address.country}</p>
    </div>
  );
}

export default App;

Author

This usegeoaddress hook was developed by therohantomar. For any inquiries or feedback, please contact me at therohantomar@gmail.com.

Feel free to customize the readme file further based on your specific requirements or additional information you'd like to provide. Member

The author's name should be mentioned as "therohantomar" and the email address as "therohantomar@gmail.com".