Skip to content

therohantomar/usegeoaddress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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".

About

The usegeoaddress hook is a custom hook that allows retrieving the user's geolocation address using the browser's Geolocation API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published