usegeoip

0.1.5 • Public • Published

📍 useGeoIp

Simple React hook for getting extensive geolocation data on current user IP address.

🚀 Getting Started

Usage of the useGeoIp React hook

Add to your project npm i usegeoip or using yarn yarn add usegeoip.

Simply import the hook in your component.

import useGeoIp from 'usegeoip';

Then you can destruct any of the available properties from the hooks return value (object). Please note that it will be empty object until result is presented thus regular nullcheck higher in the hierarchy might be in place.

const { country } = useGeoIp();

Available properties

  • businessName
  • businessWebsite
  • city
  • continent
  • country
  • countryCode
  • ipName
  • ipType
  • isp
  • lat
  • lon
  • org
  • query
  • region
  • status

All properties typed as strings.

If there's trouble there will only be one property in the response, namely error containing a javascript error.

/usegeoip/

    Package Sidebar

    Install

    npm i usegeoip

    Weekly Downloads

    1

    Version

    0.1.5

    License

    MIT

    Unpacked Size

    4.28 kB

    Total Files

    4

    Last publish

    Collaborators

    • maxomolin