0.1.5 • Published 4 years ago
usegeoip v0.1.5
📍 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.