0.1.2 • Published 4 years ago
use-geoip v0.1.2
useGeoIp: Get geolocation data on current user IP
Simple hook for fetching geolocation data based on users ip address.
🚀 Getting Started
Usage of the useGeoIp React hook
Simply use the hook from within 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 undefined 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.